* { box-sizing: border-box; margin: 0; padding: 0; }
body { font-family: "Microsoft YaHei", "PingFang SC", sans-serif; font-size: 14px; color: #1f2937; background: #f3f4f6; height: 100vh; overflow: hidden; }
button { cursor: pointer; }
input, select, textarea { font-family: inherit; font-size: 13px; padding: 7px 9px; border: 1px solid #d1d5db; border-radius: 6px; width: 100%; background: #fff; }
input:focus, select:focus, textarea:focus { outline: none; border-color: #2563eb; }
h3 { font-size: 14px; margin: 16px 0 8px; color: #111827; border-left: 3px solid #2563eb; padding-left: 8px; }
h3:first-child { margin-top: 0; }

.btn { border: 1px solid #d1d5db; background: #fff; color: #374151; padding: 7px 14px; border-radius: 6px; font-size: 13px; }
.btn:hover { background: #f9fafb; }
.btn.primary { background: #2563eb; border-color: #2563eb; color: #fff; }
.btn.primary:hover { background: #1d4ed8; }
.btn.danger { color: #dc2626; border-color: #fca5a5; }
.btn.danger:hover { background: #fef2f2; }
.btn.ghost { background: transparent; border-color: rgba(255,255,255,.4); color: inherit; }
.btn.block { display: block; width: 100%; margin-top: 8px; }
.btn.small { padding: 3px 8px; font-size: 12px; }

/* 登录 */
#login-view { height: 100vh; display: flex; align-items: center; justify-content: center; background: linear-gradient(135deg, #1e3a8a, #2563eb); }
.login-card { width: 360px; background: #fff; border-radius: 12px; padding: 32px 28px; box-shadow: 0 20px 50px rgba(0,0,0,.3); display: flex; flex-direction: column; gap: 8px; }
.login-logo { font-size: 22px; font-weight: 700; text-align: center; color: #1e3a8a; }
.login-sub { text-align: center; color: #6b7280; font-size: 12px; margin-bottom: 14px; }
.login-card label { font-size: 12px; color: #6b7280; }
#login-btn { margin-top: 12px; }
.err { color: #dc2626; font-size: 12px; min-height: 16px; }
.login-tip { font-size: 11px; color: #9ca3af; text-align: center; margin-top: 6px; }

/* 主框架 */
#main-view { height: 100vh; display: flex; flex-direction: column; }
.topbar { height: 52px; background: #1e3a8a; color: #fff; display: flex; align-items: center; padding: 0 16px; gap: 24px; flex-shrink: 0; }
.brand { font-weight: 700; font-size: 16px; }
.tabs { display: flex; gap: 4px; flex: 1; }
.tab { background: transparent; border: none; color: rgba(255,255,255,.75); padding: 8px 16px; border-radius: 6px; font-size: 14px; }
.tab.active { background: rgba(255,255,255,.18); color: #fff; }
.topbar-right { display: flex; align-items: center; gap: 10px; font-size: 13px; }

/* 视图布局 */
.view { flex: 1; display: flex; overflow: hidden; }
.side { width: 300px; background: #fff; border-right: 1px solid #e5e7eb; padding: 14px; overflow-y: auto; flex-shrink: 0; }
.side.right-col { width: 300px; border-right: none; border-left: 1px solid #e5e7eb; }
.field { margin-bottom: 8px; }
.field label { display: block; font-size: 12px; color: #6b7280; margin-bottom: 3px; }
.row2 { display: flex; gap: 8px; }
.row2 .field { flex: 1; }
.hint { font-size: 11px; color: #9ca3af; margin: 6px 0 10px; line-height: 1.5; }
.chk { display: flex; align-items: center; gap: 6px; font-size: 12px; color: #4b5563; margin: 6px 0; }
.chk input { width: auto; }
.addrow { display: flex; gap: 6px; margin-bottom: 8px; }
.addrow input { flex: 1; }

.map-slot { flex: 1; position: relative; }
#map { position: absolute; inset: 0; }

/* 统计与图例 */
.stat-row { display: flex; flex-wrap: wrap; gap: 6px; margin: 10px 0; }
.chip { background: #eff6ff; color: #1d4ed8; font-size: 11px; padding: 3px 8px; border-radius: 10px; }
.chip b { font-size: 12px; }
.legend { display: flex; flex-wrap: wrap; gap: 8px; font-size: 11px; color: #6b7280; margin: 8px 0 12px; }
.legend span { display: flex; align-items: center; gap: 4px; }
.legend i { width: 10px; height: 10px; border-radius: 50%; display: inline-block; }

/* 详情面板 */
.detail { width: 300px; background: #fff; border-left: 1px solid #e5e7eb; padding: 14px; overflow-y: auto; flex-shrink: 0; }
.detail-head { display: flex; justify-content: space-between; align-items: center; }
.detail-head h3 { border: none; padding: 0; margin: 0; }
.kv { margin-bottom: 6px; font-size: 13px; line-height: 1.5; }
.kv .k { color: #9ca3af; margin-right: 6px; }
.detail img { max-width: 100%; border-radius: 6px; margin-top: 8px; }
.detail-actions { display: flex; gap: 8px; margin-top: 12px; }

/* 列表 */
.list { display: flex; flex-direction: column; gap: 6px; margin-bottom: 12px; }
.item { border: 1px solid #e5e7eb; border-radius: 8px; padding: 8px 10px; font-size: 12px; }
.item .t { font-weight: 600; font-size: 13px; display: flex; justify-content: space-between; align-items: center; }
.item .s { color: #6b7280; margin-top: 3px; line-height: 1.5; }
.tag { font-size: 10px; padding: 2px 6px; border-radius: 8px; color: #fff; flex-shrink: 0; }
.item-actions { margin-top: 5px; display: flex; gap: 6px; }

/* 管理端 */
.admin-view { background: #f3f4f6; padding: 16px; overflow-y: auto; display: block; }
.admin-grid { display: grid; grid-template-columns: 1fr 1.4fr 1fr; gap: 16px; max-width: 1200px; margin: 0 auto; }
.panel { background: #fff; border-radius: 10px; padding: 16px; box-shadow: 0 1px 3px rgba(0,0,0,.08); }

/* 点位列表 */
.list-main { flex: 1; overflow: auto; background: #fff; padding: 14px 18px; }
.table-wrap { overflow-x: auto; }
#point-table { width: 100%; border-collapse: collapse; min-width: 820px; font-size: 13px; }
#point-table th { text-align: left; padding: 9px 10px; background: #f9fafb; color: #6b7280; font-weight: 600; border-bottom: 1px solid #e5e7eb; white-space: nowrap; position: sticky; top: 0; z-index: 1; }
#point-table td { padding: 9px 10px; border-bottom: 1px solid #f3f4f6; vertical-align: middle; }
#point-table tbody tr:hover td { background: #f8fafc; }
.td-hier { color: #6b7280; font-size: 12px; white-space: nowrap; max-width: 240px; }
.td-name { font-weight: 600; }
.td-addr { font-weight: 400; color: #9ca3af; font-size: 11px; margin-top: 2px; }
.td-acts { white-space: nowrap; }
.td-acts .btn { margin-right: 4px; margin-bottom: 2px; }
.empty { color: #9ca3af; text-align: center; padding: 36px 0 !important; }

/* 地图弹出层 */
.leaflet-popup-content { font-size: 13px; line-height: 1.6; }
.pick-tip { position: absolute; top: 12px; left: 50%; transform: translateX(-50%); background: #1e3a8a; color: #fff; padding: 8px 18px; border-radius: 20px; font-size: 13px; z-index: 1000; box-shadow: 0 4px 12px rgba(0,0,0,.25); }

#toast { position: fixed; bottom: 30px; left: 50%; transform: translateX(-50%); background: #111827; color: #fff; padding: 10px 20px; border-radius: 8px; font-size: 13px; opacity: 0; transition: opacity .3s; pointer-events: none; z-index: 9999; }
/* 打卡待确认的可拖动标记 */
.ck-pin { width: 20px; height: 20px; border-radius: 50%; background: #ef4444; border: 3px solid #fff; box-shadow: 0 2px 8px rgba(0,0,0,.45); box-sizing: border-box; animation: ck-pulse 1.4s ease-out infinite; }
@keyframes ck-pulse { 0% { box-shadow: 0 0 0 0 rgba(239,68,68,.55); } 70% { box-shadow: 0 0 0 12px rgba(239,68,68,0); } 100% { box-shadow: 0 0 0 0 rgba(239,68,68,0); } }
#checkin-status a { color: #dc2626; text-decoration: underline; cursor: pointer; }
#toast.show { opacity: 1; }

/* ================= 手机端适配 (≤820px) ================= */
@media (max-width: 820px) {
  #login-view { height: 100dvh; }
  .login-card { width: min(360px, 92vw); padding: 24px 20px; }

  #main-view { height: 100dvh; }
  .topbar { height: 46px; padding: 0 8px; gap: 8px; }
  .brand { font-size: 14px; white-space: nowrap; }
  .tab { padding: 7px 10px; font-size: 13px; }
  .topbar-right { font-size: 12px; gap: 6px; }

  /* 三个视图统一改为纵向堆叠, 页面整体滚动 */
  .view { flex-direction: column; overflow-y: auto; -webkit-overflow-scrolling: touch; }
  .side, .side.right-col { width: 100%; flex: none; border: none; border-bottom: 1px solid #e5e7eb; padding: 12px; overflow: visible; }
  .side.right-col { border-top: 1px solid #e5e7eb; }
  .map-slot { flex: none; height: 46vh; min-height: 280px; border-bottom: 1px solid #e5e7eb; }

  /* 地图总览: 地图置顶, 筛选面板放地图下方 */
  #view-overview .map-slot { order: -1; }

  /* 点位详情改为底部弹层 */
  .detail { position: fixed; left: 0; right: 0; bottom: 0; width: 100%; max-height: 68vh; z-index: 1200; border: none; border-radius: 14px 14px 0 0; box-shadow: 0 -8px 30px rgba(0,0,0,.25); }

  /* 管理端单列 */
  .admin-view { padding: 10px; }
  .admin-grid { grid-template-columns: 1fr; gap: 12px; }
  .row2 { flex-wrap: wrap; }

  /* 点位列表: 筛选在上, 表格横向滚动 */
  .list-main { overflow: visible; padding: 10px 12px; }
  .table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; border: 1px solid #e5e7eb; border-radius: 8px; }
}
@media (max-width: 480px) {
  .topbar-right #whoami { display: none; }
  .brand { display: none; }
  .tabs { justify-content: space-around; flex: 1; }
  .detail { max-height: 76vh; }
}
