:root {
  --bg: #f4f6fb;
  --card: #ffffff;
  --border: #e3e8f0;
  --text: #1c2333;
  --muted: #6b7280;
  --primary: #2563eb;
  --primary-dark: #1d4ed8;
  --success: #16a34a;
  --danger: #dc2626;
  --warning: #d97706;
  --radius: 12px;
  --shadow: 0 1px 3px rgba(16, 24, 40, 0.08), 0 4px 16px rgba(16, 24, 40, 0.06);
}

* { box-sizing: border-box; }

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

a { color: var(--primary); text-decoration: none; }

/* ---------- 通用容器 ---------- */
.container { max-width: 1080px; margin: 0 auto; padding: 20px 16px 60px; }

.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 20px;
  margin-bottom: 16px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 16px;
}
.topbar h1 { font-size: 20px; margin: 0; }

.brand { display: flex; align-items: center; gap: 8px; font-weight: 700; font-size: 16px; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  border: none; border-radius: 8px; cursor: pointer;
  padding: 10px 16px; font-size: 14px; font-weight: 600;
  background: var(--primary); color: #fff; transition: background .15s;
}
.btn:hover { background: var(--primary-dark); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn.secondary { background: #eef2f7; color: var(--text); }
.btn.secondary:hover { background: #e2e8f0; }
.btn.danger { background: var(--danger); }
.btn.small { padding: 6px 10px; font-size: 13px; }
.btn.block { width: 100%; }

/* ---------- 表单 ---------- */
label { display: block; font-size: 13px; color: var(--muted); margin-bottom: 4px; }
input, select, textarea {
  width: 100%; padding: 10px 12px; font-size: 14px;
  border: 1px solid var(--border); border-radius: 8px; background: #fff;
  color: var(--text); font-family: inherit;
}
input:focus, select:focus, textarea:focus {
  outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px rgba(37, 99, 235, .12);
}
.field { margin-bottom: 14px; }
.row { display: flex; gap: 12px; }
.row > * { flex: 1; }
.hint { font-size: 12px; color: var(--muted); margin-top: 4px; }

/* ---------- 表格 ---------- */
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th, td { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--border); vertical-align: top; }
th { color: var(--muted); font-weight: 600; background: #fafbfd; white-space: nowrap; }
tr:hover td { background: #fafbff; }
.table-wrap { overflow-x: auto; }

.tag { display: inline-block; padding: 2px 8px; border-radius: 999px; font-size: 12px; font-weight: 600; }
.tag.ok { background: #dcfce7; color: #15803d; }
.tag.fail { background: #fee2e2; color: #b91c1c; }
.tag.warn { background: #fef3c7; color: #b45309; }
.tag.gray { background: #eef2f7; color: #475569; }

/* ---------- 状态提示 ---------- */
.alert { padding: 12px 14px; border-radius: 8px; font-size: 14px; margin-bottom: 14px; }
.alert.error { background: #fef2f2; color: #b91c1c; border: 1px solid #fecaca; }
.alert.success { background: #f0fdf4; color: #15803d; border: 1px solid #bbf7d0; }
.alert.info { background: #eff6ff; color: #1d4ed8; border: 1px solid #bfdbfe; }

/* ---------- 打卡页 ---------- */
.punch-shell { max-width: 520px; margin: 0 auto; }
.camera-box {
  position: relative; background: #0b1220; border-radius: var(--radius);
  overflow: hidden; aspect-ratio: 4 / 3;
}
.camera-box video { width: 100%; height: 100%; object-fit: cover; display: block; }
.camera-box canvas.overlay { position: absolute; inset: 0; width: 100%; height: 100%; }
.camera-box .placeholder {
  position: absolute; inset: 0; display: flex; align-items: center; justify-content: center;
  color: #9ca3af; font-size: 14px;
}

.check-list { margin: 0; padding: 0; list-style: none; }
.check-list li {
  display: flex; align-items: center; gap: 10px; padding: 10px 0;
  border-bottom: 1px dashed var(--border); font-size: 14px;
}
.check-list li:last-child { border-bottom: none; }
.check-list .icon { width: 24px; height: 24px; flex: none; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-size: 13px; }
.check-list .icon.ok { background: #dcfce7; color: #15803d; }
.check-list .icon.fail { background: #fee2e2; color: #b91c1c; }
.check-list .icon.off { background: #eef2f7; color: #94a3b8; }
.check-list .detail { color: var(--muted); font-size: 12px; }

.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 12px; }
.stat {
  background: var(--card); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 16px; text-align: center;
}
.stat .num { font-size: 28px; font-weight: 700; }
.stat .label { font-size: 13px; color: var(--muted); margin-top: 2px; }

/* ---------- 登录页 ---------- */
.login-box { max-width: 360px; margin: 80px auto; }

/* ---------- 标签页 ---------- */
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border); margin-bottom: 16px; flex-wrap: wrap; }
.tabs button {
  background: none; border: none; padding: 10px 14px; cursor: pointer;
  font-size: 14px; color: var(--muted); border-bottom: 2px solid transparent; font-weight: 600;
}
.tabs button.active { color: var(--primary); border-bottom-color: var(--primary); }
.tab-panel { display: none; }
.tab-panel.active { display: block; }

/* ---------- 地图选点 ---------- */
.map-toolbar { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 6px; }
#siteMap { position: relative; z-index: 0; height: 320px; border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; }
.site-pin { background: none; border: none; }
.site-pin .pin-dot {
  width: 16px; height: 16px; border-radius: 50%;
  background: var(--primary); border: 3px solid #fff;
  box-shadow: 0 0 0 2px var(--primary), 0 2px 6px rgba(0, 0, 0, .3);
  transform: translate(-1px, -1px);
}

@media (max-width: 600px) {
  .row { flex-direction: column; gap: 0; }
  .btn { width: 100%; }
}
