:root {
  --bg: #0f172a;
  --panel: rgba(255, 255, 255, 0.96);
  --primary: #2563eb;
  --text: #1e293b;
  --muted: #64748b;
  --danger: #dc2626;
  --ok: #16a34a;
}
* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; font-family: -apple-system, "PingFang SC", "Microsoft YaHei", sans-serif; }
.hidden { display: none !important; }
button {
  border: none; border-radius: 8px; padding: 8px 14px; cursor: pointer;
  background: var(--primary); color: #fff; font-size: 14px;
}
button.ghost {
  background: rgba(255,255,255,.9); color: var(--text);
  border: 1px solid #e2e8f0;
}
button.ghost:hover { background: #f1f5f9; }
.err { color: var(--danger); font-size: 13px; margin-top: 8px; }
.hint { color: var(--muted); font-size: 12px; }

/* 登录 */
.login-view {
  height: 100vh; display: flex; align-items: center; justify-content: center;
  background: linear-gradient(160deg, #1e3a8a, #0f172a);
}
.login-card {
  width: 340px; padding: 36px 30px; border-radius: 16px;
  background: var(--panel); text-align: center;
  box-shadow: 0 20px 50px rgba(0,0,0,.4);
}
.login-logo { font-size: 40px; }
.login-card h1 { font-size: 22px; margin: 8px 0 4px; color: var(--text); }
.login-card .sub { color: var(--muted); font-size: 13px; margin-bottom: 22px; }
.login-card input {
  width: 100%; padding: 11px 12px; margin-bottom: 12px;
  border: 1px solid #cbd5e1; border-radius: 8px; font-size: 14px;
}
.login-card button { width: 100%; padding: 11px; font-size: 15px; }
.admin-login { margin-top: 16px; font-size: 13px; }
.admin-login a { color: var(--primary); text-decoration: none; }

/* 主界面 */
.main-view { height: 100vh; position: relative; }
/* z-index:0 + isolation 让 #map 自成一个层叠上下文：
   腾讯地图内部控件用的是很大的 z-index，若不隔离会盖到顶栏之上并吞掉点击 */
#map { position: absolute; inset: 0; z-index: 0; isolation: isolate; }
.topbar {
  position: absolute; top: 0; left: 0; right: 0; z-index: 2000;
  display: flex; align-items: center; gap: 8px;
  padding: 10px 14px; background: rgba(255,255,255,.97);
  box-shadow: 0 1px 6px rgba(0,0,0,.15);
}
.topbar .brand { font-weight: 700; color: var(--text); flex: none; white-space: nowrap; }
.topbar .spacer { flex: 1 1 0; min-width: 0; }
.topbar button { flex: none; white-space: nowrap; }
.topbar .me {
  color: var(--primary); font-weight: 600; font-size: 14px;
  flex: 0 1 auto; min-width: 0; max-width: 72px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}

.sidebar {
  position: absolute; top: 58px; left: 14px; width: 250px; max-height: calc(100vh - 80px);
  overflow-y: auto; z-index: 2000; background: var(--panel);
  border-radius: 12px; box-shadow: 0 4px 16px rgba(0,0,0,.18); padding: 12px;
}
.ver { margin-top: 10px; text-align: right; font-size: 11px; color: #94a3b8; }
.side-actions { display: flex; gap: 8px; margin-top: 10px; }
.side-actions button { flex: 1 1 0; min-width: 0; padding: 6px 4px; font-size: 12px; }
.share-box { display: flex; align-items: center; gap: 12px; padding-bottom: 10px; border-bottom: 1px solid #e2e8f0; }
.share-text b { display: block; font-size: 14px; color: var(--text); }
.share-text span { font-size: 12px; color: var(--muted); }
.switch { position: relative; width: 44px; height: 24px; flex: none; }
.switch input { opacity: 0; width: 0; height: 0; }
.slider {
  position: absolute; inset: 0; background: #cbd5e1; border-radius: 24px;
  transition: .2s; cursor: pointer;
}
.slider:before {
  content: ""; position: absolute; width: 18px; height: 18px; left: 3px; top: 3px;
  background: #fff; border-radius: 50%; transition: .2s;
}
.switch input:checked + .slider { background: var(--ok); }
.switch input:checked + .slider:before { transform: translateX(20px); }

.side-title { margin: 10px 0 6px; font-size: 13px; color: var(--muted); }
#memberList { list-style: none; }
#memberList li {
  display: flex; align-items: center; gap: 8px; padding: 7px 6px;
  border-radius: 8px; cursor: pointer; font-size: 14px; color: var(--text);
}
#memberList li:hover { background: #f1f5f9; }
#memberList li.me-row { background: #eff6ff; }
.dot { width: 9px; height: 9px; border-radius: 50%; flex: none; background: #94a3b8; }
.dot.on { background: var(--ok); }
.last-ts { margin-left: auto; font-size: 11px; color: var(--muted); }
.key-warn { margin-top: 10px; font-size: 12px; color: #b45309; background: #fef3c7; padding: 8px; border-radius: 8px; }

/* 弹窗 */
.modal-mask {
  position: fixed; inset: 0; z-index: 3000; background: rgba(15,23,42,.45);
  display: flex; align-items: center; justify-content: center; padding: 16px;
}
.modal {
  width: 480px; max-width: 94vw; max-height: 86vh; overflow-y: auto;
  background: #fff; border-radius: 14px; padding: 18px;
}
.modal.small { width: 340px; }
.modal-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 14px; }
.modal-body input {
  width: 100%; padding: 10px 12px; margin-bottom: 10px;
  border: 1px solid #cbd5e1; border-radius: 8px; font-size: 14px;
}
.form-row { display: flex; gap: 8px; margin-bottom: 14px; }
.form-row input { margin-bottom: 0; }
.form-col { margin-top: 18px; display: flex; flex-direction: column; gap: 8px; }
.user-table { width: 100%; border-collapse: collapse; font-size: 13px; margin-bottom: 8px; }
.user-table th, .user-table td { padding: 7px 6px; text-align: left; border-bottom: 1px solid #e2e8f0; }
.user-table th { color: var(--muted); font-weight: 600; }

/* 手机适配 */
@media (max-width: 640px) {
  .sidebar { width: 210px; top: 54px; }
  .topbar { padding: 8px 10px; gap: 6px; }
  .topbar button { padding: 6px 9px; font-size: 12px; }
  .topbar .me { max-width: 56px; font-size: 12px; }
}
/* 窄屏：隐藏品牌文字只留图标，保证所有按钮都在屏内 */
@media (max-width: 430px) {
  .topbar .brand-txt { display: none; }
}
@media (max-width: 360px) {
  .topbar { gap: 4px; padding: 6px 8px; }
  .topbar button { padding: 6px 7px; font-size: 11px; }
}

/* 运行时错误条（默认隐藏，出问题时自动出现，便于远程排查） */
.err-bar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 5000;
  max-height: 40vh; overflow: auto; pointer-events: none;
  background: rgba(220,38,38,.95); color: #fff;
  font: 12px/1.5 ui-monospace, Menlo, Consolas, monospace;
  padding: 8px 12px; white-space: pre-wrap;
}
