/* ============================================
   位置分享 - 管理后台样式
   ============================================ */
* { margin: 0; padding: 0; box-sizing: border-box; }

:root {
  --primary: #2563eb;
  --primary-dark: #1d4ed8;
  --bg: #f1f5f9;
  --card: #ffffff;
  --text: #1e293b;
  --muted: #64748b;
  --border: #e2e8f0;
  --danger: #dc2626;
  --ok: #16a34a;
  --radius: 12px;
  --sidebar-w: 210px;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
    "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
}

/* ---------- 登录页 ---------- */
.login-body {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(160deg, #eff6ff, #f1f5f9);
}
.login-box {
  width: 380px; max-width: 92vw;
  background: var(--card);
  border-radius: 16px;
  padding: 34px;
  box-shadow: 0 10px 30px rgba(15, 23, 42, .08);
  border: 1px solid var(--border);
}
.login-brand { font-size: 26px; font-weight: 800; color: var(--primary); text-align: center; }
.login-sub { text-align: center; color: var(--muted); font-size: 14px; margin: 6px 0 22px; }
.login-foot { text-align: center; margin-top: 18px; font-size: 13px; }
.login-foot a { color: var(--primary); text-decoration: none; }

/* ---------- 布局 ---------- */
.sidebar {
  position: fixed; top: 0; left: 0; bottom: 0;
  width: var(--sidebar-w);
  background: #0f172a;
  display: flex; flex-direction: column;
  padding: 18px 0;
  z-index: 10;
}
.sidebar-brand {
  color: #fff; font-size: 18px; font-weight: 800;
  padding: 6px 22px 20px;
  border-bottom: 1px solid rgba(255, 255, 255, .08);
}
.sidebar-nav { flex: 1; padding-top: 14px; }
.nav-item {
  display: block; color: #94a3b8; text-decoration: none;
  padding: 10px 22px; font-size: 14px;
  border-left: 3px solid transparent;
  transition: all .15s;
}
.nav-item:hover { color: #fff; background: rgba(255, 255, 255, .05); }
.nav-item.active { color: #fff; background: rgba(37, 99, 235, .25); border-left-color: var(--primary); }
.sidebar-foot { border-top: 1px solid rgba(255, 255, 255, .08); padding-top: 10px; }

.main { margin-left: var(--sidebar-w); padding: 26px 30px 50px; }

/* ---------- 页面标题 ---------- */
.page-head { margin-bottom: 20px; }
.page-head h1 { font-size: 22px; }
.page-head .muted { font-size: 13px; }

/* ---------- 统计卡 ---------- */
.stat-grid {
  display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px;
  margin-bottom: 22px;
}
.stat-card {
  background: var(--card); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 18px;
}
.stat-num { font-size: 28px; font-weight: 800; color: var(--primary); }
.stat-label { font-size: 13px; color: var(--muted); margin-top: 4px; }

/* ---------- 卡片 ---------- */
.card {
  background: var(--card); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 20px; margin-bottom: 20px;
}
.card-head {
  display: flex; justify-content: space-between; align-items: center;
  margin-bottom: 14px;
}
.card-head h2 { font-size: 16px; }
.muted { color: var(--muted); font-size: 13px; }
.card .muted { margin-bottom: 6px; }

/* ---------- 表格 ---------- */
.table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.table th, .table td { padding: 10px 12px; text-align: left; border-bottom: 1px solid var(--border); }
.table th { color: var(--muted); font-weight: 600; background: #f8fafc; white-space: nowrap; }
.table tr:hover td { background: #f8fafc; }
.cell-time { white-space: nowrap; }
.cell-coord { white-space: nowrap; font-variant-numeric: tabular-nums; }
.cell-addr { max-width: 320px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.table code { background: #f1f5f9; padding: 2px 6px; border-radius: 5px; font-size: 12.5px; }

/* ---------- 表单 ---------- */
.form .form-group { margin-bottom: 16px; }
.form-group label { display: block; font-size: 13px; font-weight: 600; margin-bottom: 6px; }
.form-inline { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.input {
  padding: 9px 12px; border: 1px solid var(--border);
  border-radius: 8px; font-size: 14px; font-family: inherit;
  width: 100%; color: var(--text);
}
.input:focus { outline: none; border-color: var(--primary); }
textarea.input { resize: vertical; min-height: 100px; }

/* ---------- 按钮 ---------- */
.btn {
  display: inline-block; border: none; border-radius: 8px;
  padding: 8px 16px; font-size: 13.5px; font-weight: 600;
  cursor: pointer; text-decoration: none; text-align: center; font-family: inherit;
}
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dark); }
.btn-ghost { background: #fff; color: var(--primary); border: 1px solid #bfdbfe; }
.btn-ghost:hover { background: #eff6ff; }
.btn-danger { background: #fff; color: var(--danger); border: 1px solid #fecaca; }
.btn-danger:hover { background: #fef2f2; }
.btn-sm { padding: 5px 11px; font-size: 12.5px; }
.inline-form { display: inline-block; margin-left: 6px; }
.input-sm { width: 90px; padding: 5px 8px; font-size: 12.5px; }

/* 侧栏用户信息 */
.side-user { padding: 10px 16px; font-size: 13px; color: var(--muted); }
.side-quota { display: block; margin-top: 2px; font-size: 12px; color: var(--primary); }

/* 用户管理操作面板 */
.user-actions { position: relative; display: inline-block; }
.user-actions summary { list-style: none; cursor: pointer; }
.user-actions-panel {
  position: absolute; right: 0; top: 100%; z-index: 20;
  background: #fff; border: 1px solid var(--border); border-radius: 10px;
  box-shadow: 0 6px 20px rgba(0,0,0,.10);
  padding: 10px; min-width: 300px;
}
.user-actions-panel form { display: flex; gap: 6px; margin-bottom: 8px; }
.user-actions-panel form:last-child { margin-bottom: 0; }
.btn-block { display: block; width: 100%; }

/* ---------- 徽章 ---------- */
.badge {
  display: inline-block; padding: 3px 10px; border-radius: 999px;
  font-size: 12px; font-weight: 600;
}
.badge-ok { background: #f0fdf4; color: var(--ok); border: 1px solid #bbf7d0; }
.badge-used { background: #fef2f2; color: var(--danger); border: 1px solid #fecaca; }
.badge-muted { background: #f1f5f9; color: var(--muted); border: 1px solid var(--border); }

/* ---------- 提示 ---------- */
.alert { border-radius: 10px; padding: 11px 14px; margin-bottom: 18px; font-size: 13.5px; }
.alert-error { background: #fef2f2; border: 1px solid #fecaca; color: var(--danger); }
.alert-ok { background: #f0fdf4; border: 1px solid #bbf7d0; color: var(--ok); word-break: break-all; }

/* ---------- 授权码操作栏 & 一键复制提示 ---------- */
.codes-actions { display: flex; align-items: center; flex-wrap: wrap; }
.codes-actions > * { margin-left: 8px; }
.codes-actions > *:first-child { margin-left: 0; }
.admin-toast {
  position: fixed;
  left: 50%;
  bottom: 40px;
  transform: translateX(-50%) translateY(16px);
  background: #0f172a;
  color: #fff;
  padding: 10px 20px;
  border-radius: 8px;
  font-size: 13.5px;
  opacity: 0;
  pointer-events: none;
  transition: all .3s;
  z-index: 999;
}
.admin-toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ---------- 链接行 ---------- */
.link-row { display: flex; gap: 10px; }
.link-row .input { flex: 1; }

/* ---------- 地图标记 ---------- */
.loc-marker { background: transparent; border: none; }
.leaflet-popup-content { font-size: 13px; }

/* ---------- 响应式 ---------- */
@media (max-width: 900px) {
  .stat-grid { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 640px) {
  .sidebar { position: static; width: 100%; flex-direction: row; align-items: center; padding: 8px 14px; }
  .sidebar-brand { border-bottom: none; padding: 4px 14px 4px 0; font-size: 15px; }
  .sidebar-nav { display: flex; gap: 4px; padding: 0; flex: 1; overflow-x: auto; }
  .nav-item { padding: 8px 12px; border-left: none; border-bottom: 2px solid transparent; white-space: nowrap; font-size: 13px; }
  .nav-item.active { border-bottom-color: var(--primary); border-left: none; }
  .sidebar-foot { border-top: none; padding: 0; }
  .main { margin-left: 0; padding: 18px 14px 40px; }
  .table { font-size: 12.5px; }
}
