* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; padding: 0; height: 100%; font-family: -apple-system, "PingFang SC", "Microsoft YaHei", sans-serif; background: #f5f6f8; color: #1f2329; }
a { color: inherit; text-decoration: none; }

/* 登录页 */
.login-wrap { min-height: 100%; display: flex; align-items: center; justify-content: center; padding: 24px; }
.login-card { width: 100%; max-width: 380px; background: #fff; border-radius: 16px; padding: 32px 24px; box-shadow: 0 8px 30px rgba(0,0,0,.08); }
.login-card h1 { font-size: 20px; margin: 0 0 4px; }
.login-card .sub { color: #8a9099; font-size: 13px; margin-bottom: 24px; }
.field { margin-bottom: 16px; }
.field label { display: block; font-size: 13px; color: #5a6068; margin-bottom: 6px; }
.field input, .field select { width: 100%; height: 44px; border: 1px solid #dfe3e8; border-radius: 10px; padding: 0 12px; font-size: 15px; outline: none; }
.field input:focus, .field select:focus { border-color: #2f6bff; }
.btn { width: 100%; height: 46px; border: none; border-radius: 10px; background: #2f6bff; color: #fff; font-size: 16px; font-weight: 600; cursor: pointer; }
.btn:active { background: #2257e0; }
.captcha-row { display: flex; gap: 10px; align-items: center; }
.captcha-row input { flex: 1; }
.captcha-row img { width: 120px; height: 40px; border: 1px solid #dfe3e8; border-radius: 10px; cursor: pointer; background: #f8fafc; }
.btn.ghost { background: #eef1f5; color: #39414c; }
.btn.danger { background: #ff4d4f; }
.btn.sm { height: 34px; font-size: 13px; padding: 0 12px; width: auto; border-radius: 8px; }
.msg { font-size: 13px; color: #ff4d4f; min-height: 18px; margin-bottom: 8px; }

/* 地图页 */
.app-bar { position: fixed; top: 0; left: 0; right: 0; height: 52px; background: rgba(255,255,255,.96); backdrop-filter: blur(8px); display: flex; align-items: center; padding: 0 14px; z-index: 1000; border-bottom: 1px solid #eceef1; }
.app-bar .title { font-weight: 600; font-size: 16px; }
.app-bar .spacer { flex: 1; }
.app-bar .who { font-size: 12px; color: #6b7280; margin-right: 10px; }
.app-bar .icon-btn { border: none; background: #eef1f5; height: 34px; padding: 0 12px; border-radius: 8px; font-size: 13px; margin-left: 8px; cursor: pointer; }
.app-bar .icon-btn.active { background: #2f6bff; color: #fff; }
/* 统一筛选区 */
.filters-wrap {
  position: fixed; top: 52px; left: 0; right: 0;
  background: rgba(255,255,255,.98); backdrop-filter: blur(8px);
  border-bottom: 1px solid #eceef1;
  padding: 10px 14px;
  display: flex; flex-direction: column; gap: 10px;
  z-index: 999;
  max-height: 60vh;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}
/* 筛选区抽屉头：展开/收起统一由它控制（桌面+移动端都显示） */
.filters-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 2px 2px 6px; cursor: pointer; user-select: none;
  border-bottom: 1px solid #eef1f4;
}
.filters-head-title { font-size: 14px; font-weight: 600; display: flex; align-items: center; gap: 8px; }
.filters-head-tip {
  font-size: 11px; font-weight: 400; color: #2f6bff;
  background: #eef4ff; border-radius: 999px; padding: 2px 8px;
  animation: pot-pulse 1.6s ease-in-out infinite;
}
.filters-head-tip.collapse { display: none; animation: none; color: #6b7280; background: #f1f2f4; }
.filters-head-arrow { color: #8a9099; transition: transform .2s ease; font-size: 14px; }
.filters-wrap.expanded .filters-head-arrow { transform: rotate(180deg); }
.filters-wrap.expanded .filters-head-tip { display: none; }
.filters-wrap.expanded .filters-head-tip.collapse { display: inline-block; }
/* 收起时隐藏筛选行（默认状态）；展开时显示 */
.filters-wrap:not(.expanded) .filter-row { display: none; }

.filter-row { display: flex; align-items: flex-start; gap: 10px; }
.filter-row.search-row { align-items: center; }

.filter-label {
  flex: 0 0 76px;
  text-align: right;
  font-size: 13px; color: #6b7280;
  line-height: 32px; font-weight: 500;
}

.filter-options {
  flex: 1;
  display: flex; flex-wrap: wrap; gap: 8px;
  min-width: 0;
}

/* 胶囊筛选项 */
.filter-tag {
  display: inline-flex; align-items: center;
  height: 30px; padding: 0 12px;
  border: 1px solid #e5e7eb; background: #fff;
  border-radius: 999px;
  font-size: 13px; color: #4b5563;
  cursor: pointer; white-space: nowrap;
  transition: all .12s ease;
}
.filter-tag:hover { border-color: #2f6bff; color: #2f6bff; }
.filter-tag.active {
  background: #2f6bff; border-color: #2f6bff; color: #fff;
}
.filter-tag.primary {
  background: #eef4ff; border-color: #2f6bff; color: #2f6bff; font-weight: 600;
}
.filter-tag.primary.active {
  background: #1d4ed8; border-color: #1d4ed8; color: #fff;
}
/* 潜力分级胶囊：按算法配色（与地图网格一致），选中态填充对应色 */
.filter-tag.tier-toggle[data-tier="core"] { border-color: #b2182b; color: #b2182b; }
.filter-tag.tier-toggle[data-tier="high"] { border-color: #e67e22; color: #e67e22; }
.filter-tag.tier-toggle[data-tier="mid"]  { border-color: #2f6bff; color: #2f6bff; }
.filter-tag.tier-toggle[data-tier="low"]  { border-color: #c5ccd6; color: #95a5a6; }
.filter-tag.tier-toggle[data-tier="core"].active { background: #b2182b; color: #fff; }
.filter-tag.tier-toggle[data-tier="high"].active { background: #e67e22; color: #fff; }
.filter-tag.tier-toggle[data-tier="mid"].active  { background: #2f6bff; color: #fff; }
.filter-tag.tier-toggle[data-tier="low"].active  { background: #c5ccd6; color: #fff; }

/* 搜索框 */
.search-options { position: relative; }
.search-input {
  width: 100%; max-width: 360px; height: 36px;
  padding: 0 14px 0 34px;
  border: 1px solid #e5e7eb; border-radius: 999px;
  font-size: 14px; outline: none;
  background: #f9fafb url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' fill='%239ca3af' viewBox='0 0 16 16'%3E%3Cpath d='M11.742 10.344a6.5 6.5 0 1 0-1.397 1.398h-.001c.03.04.062.078.098.115l3.85 3.85a1 1 0 0 0 1.415-1.414l-3.85-3.85a1.007 1.007 0 0 0-.115-.1zM12 6.5a5.5 5.5 0 1 1-11 0 5.5 5.5 0 0 1 11 0z'/%3E%3C/svg%3E") no-repeat 12px center;
  background-size: 16px;
  transition: all .12s ease;
}
.search-input:focus { border-color: #2f6bff; background-color: #fff; box-shadow: 0 0 0 3px rgba(47,107,255,.12); }

.search-results {
  position: absolute; top: 42px; left: 0;
  width: 100%; max-width: 360px; max-height: 60vh;
  overflow-y: auto; margin: 0; padding: 4px 0;
  list-style: none; background: #fff;
  border: 1px solid #dfe3e8; border-radius: 8px;
  box-shadow: 0 6px 22px rgba(0,0,0,.14);
  z-index: 1001;
}
.search-results li { padding: 9px 12px; cursor: pointer; border-bottom: 1px solid #f2f3f5; font-size: 13px; line-height: 1.4; }
.search-results li:last-child { border-bottom: none; }
.search-results li:hover { background: #f5f8ff; }
.sr-name { font-weight: 600; color: #1f2937; }
.sr-tag { display: inline-block; margin-left: 6px; font-size: 11px; padding: 1px 6px; border-radius: 6px; vertical-align: middle; }
.sr-tag.terminal { background: #eaf1ff; color: #2f6bff; }
.sr-tag.blank { background: #f0f1f2; color: #95a5a6; }
.sr-sub { color: #9aa3af; font-size: 12px; margin-top: 2px; }
.sr-empty { padding: 14px; color: #9aa3af; font-size: 13px; text-align: center; }

/* 地图区域 top 由 JS 根据筛选区高度动态设置 */
#map { position: absolute; top: 52px; bottom: 0; left: 0; right: 0; }

/* 移动端适配 */
@media (max-width: 640px) {
  .filters-wrap { padding: 10px 12px; gap: 8px; }
  .filter-row { flex-direction: column; gap: 6px; }
  .filter-row.search-row { flex-direction: row; align-items: center; }
  .filter-label { flex: none; text-align: left; line-height: 1.2; width: auto; }
  .search-input { max-width: none; }
  .search-results { max-width: none; width: calc(100vw - 24px); }
}
/* 终端/热力 canvas 在 overlay 面板绘制，设为不可点击，确保地图 click 事件可命中（就近终端 / 热力汇总） */
.leaflet-overlay-pane { pointer-events: none; }
.pin-canvas-layer { pointer-events: none; }
.leaflet-popup-content { font-size: 13px; line-height: 1.6; }

/* 访问统计 */
.visit-cards { display: flex; gap: 12px; flex-wrap: wrap; margin-bottom: 4px; }
.vc { flex: 1; min-width: 120px; background: #f1f5f9; border-radius: 10px; padding: 14px; text-align: center; }
.vc-num { font-size: 26px; font-weight: 700; color: #1f4fcf; line-height: 1.1; }
.vc-label { font-size: 12px; color: #64748b; margin-top: 6px; }
.tbl { width: 100%; border-collapse: collapse; font-size: 13px; }
.tbl th, .tbl td { padding: 8px 10px; border-bottom: 1px solid #eef2f7; text-align: left; white-space: nowrap; }
.tbl th { color: #64748b; font-weight: 600; background: #f8fafc; }
.tbl td.meta { color: #94a3b8; font-size: 12px; }
.leaflet-popup-content b { font-size: 14px; }
.store-dot { background: #ff7a18; border: 2px solid #fff; border-radius: 50%; box-shadow: 0 1px 4px rgba(0,0,0,.35); }
.me-dot { background: #2f6bff; border: 3px solid #fff; border-radius: 50%; box-shadow: 0 0 0 4px rgba(47,107,255,.25); }
.nav-btn { display: inline-block; margin-top: 8px; padding: 6px 12px; background: #ecf0f1; color: #000; border: 1px solid #bdc3c7; border-radius: 8px; font-size: 13px; font-weight: 600; text-align: center; }
.nav-btn:active { background: #d6dbdf; }

/* 管理页 */
.admin-nav { display: flex; position: fixed; top: 0; left: 0; right: 0; background: #fff; border-bottom: 1px solid #eceef1; z-index: 1000; }
.admin-nav button { flex: 1; height: 48px; border: none; background: none; font-size: 15px; color: #6b7280; cursor: pointer; }
.admin-nav button.active { color: #2f6bff; font-weight: 600; border-bottom: 2px solid #2f6bff; }
.admin-body { padding: 64px 14px 24px; }
.panel { display: none; }
.panel.active { display: block; }
.card { background: #fff; border-radius: 12px; padding: 14px; margin-bottom: 12px; box-shadow: 0 2px 10px rgba(0,0,0,.04); }
.card .row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.card .name { font-weight: 600; font-size: 15px; }
.card .meta { color: #8a9099; font-size: 12px; margin-top: 4px; }
.tag { font-size: 11px; padding: 2px 8px; border-radius: 999px; background: #eef1f5; color: #5a6068; }
.tag.on { background: #e6f4ea; color: #1a7f37; }
.tag.off { background: #fde8e8; color: #c0392b; }
.tag.admin { background: #eaf0ff; color: #2f6bff; }
.section-title { font-size: 14px; color: #5a6068; margin: 4px 0 10px; font-weight: 600; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.form-grid .full { grid-column: 1 / -1; }
.form-grid input, .form-grid select { height: 40px; border: 1px solid #dfe3e8; border-radius: 8px; padding: 0 10px; font-size: 14px; outline: none; width: 100%; }
.form-grid .fld-label { display: block; font-size: 13px; color: #5a6068; margin-bottom: 6px; }
.form-grid .checks { display: flex; flex-wrap: wrap; gap: 8px; }
.form-grid .checks label { display: inline-flex; align-items: center; gap: 4px; font-size: 13px; padding: 5px 10px; border: 1px solid #dfe3e8; border-radius: 8px; background: #fff; cursor: pointer; }
.form-grid .checks label.on { background: #eaf1ff; border-color: #2f6bff; color: #2f6bff; }
.form-grid .checks input { width: auto; height: auto; margin: 0; }
.back-link { font-size: 13px; color: #2f6bff; }

/* 数据导入 */
.tip { font-size: 12px; color: #6b7280; line-height: 1.6; background: #f3f6fb; border-radius: 8px; padding: 10px 12px; margin: 0 0 12px; }
.import-card .meta { line-height: 1.5; margin-top: 8px; word-break: break-all; }
.import-card .imode { height: 38px; border: 1px solid #dfe3e8; border-radius: 8px; padding: 0 8px; font-size: 13px; background: #fff; }
.import-card .ifile { flex: 1; min-width: 140px; font-size: 13px; }
.import-card .msg { margin-top: 8px; min-height: 16px; font-size: 13px; }
.import-card .btn.sm { white-space: nowrap; }

/* 网格潜力热力面板 */
.pot-panel { position: fixed; right: 10px; bottom: 10px; width: 280px; max-height: 52vh; background: #fff; border-radius: 12px; box-shadow: 0 8px 30px rgba(0,0,0,.18); z-index: 1002; display: flex; flex-direction: column; overflow: hidden; }
.pot-head { padding: 10px 12px; font-size: 14px; font-weight: 600; border-bottom: 1px solid #eee; display: flex; justify-content: space-between; align-items: center; cursor: pointer; user-select: none; }
.pot-title { display: flex; align-items: center; gap: 6px; min-width: 0; }
.pot-count { font-size: 12px; font-weight: 400; color: #8a9099; }
.pot-actions { display: inline-flex; align-items: center; gap: 8px; }
.pot-toggle { color: #8a9099; font-size: 14px; line-height: 1; padding: 2px 4px; cursor: pointer; display: none; }
.pot-panel.expanded .pot-toggle { transform: rotate(180deg); }
.pot-close { cursor: pointer; color: #9aa3af; font-size: 18px; line-height: 1; }
.pot-hint { padding: 6px 12px; font-size: 11px; color: #6b7280; background: #f5f8ff; border-bottom: 1px solid #eee; line-height: 1.5; }
/* 移动端抽屉收起时的"点击展开"引导提示 */
.pot-expand-tip {
  font-size: 11px; font-weight: 400; color: #2f6bff;
  background: #eef4ff; border-radius: 999px;
  padding: 2px 8px; white-space: nowrap;
  animation: pot-pulse 1.6s ease-in-out infinite;
}
.pot-panel.expanded .pot-expand-tip { animation: none; color: #8a9099; background: #f1f2f4; }
@keyframes pot-pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: .45; }
}
.pot-list { overflow-y: auto; padding: 6px; }
.pot-item { display: flex; gap: 8px; align-items: center; padding: 8px; border-radius: 8px; cursor: pointer; }
.pot-item:hover { background: #f5f8ff; }
.pot-tier { font-size: 13px; font-weight: 700; flex: 0 0 auto; }
.pot-core { color: #b2182b; } .pot-high { color: #e67e22; } .pot-mid { color: #2f6bff; } .pot-low { color: #95a5a6; }
.pot-info { flex: 1; min-width: 0; }
.pot-rank { font-size: 13px; font-weight: 600; }
.pot-sub { font-size: 12px; color: #8a9099; }
.pot-empty { padding: 16px; color: #9aa3af; font-size: 13px; text-align: center; }
.pot-legend { padding: 8px 12px; font-size: 11px; color: #8a9099; border-top: 1px solid #eee; display: flex; align-items: center; gap: 5px; }
.pot-legend .sw { width: 12px; height: 12px; border-radius: 3px; display: inline-block; }
.pot-grid-label { background: transparent; border: 0 !important; } /* 清除 Leaflet divIcon 默认白框 */
/* 拖动地图时隐藏潜力网格中心标签（DOM 多，是拖拽卡顿主因），停下恢复 */
body.map-dragging .pot-grid-label { display: none !important; }

/* 移动端：底部抽屉，默认只露头部，点击展开 */
@media (max-width: 640px) {
  .pot-panel {
    left: 0; right: 0; bottom: 0;
    width: auto; max-width: none;
    max-height: 70vh;
    border-radius: 16px 16px 0 0;
    box-shadow: 0 -8px 30px rgba(0,0,0,.18);
    transform: translateY(calc(100% - 48px));
    transition: transform .25s ease;
  }
  .pot-panel.expanded { transform: translateY(0); }
  .pot-toggle { display: inline-block; }
  .pot-head::before {
    content: ''; display: block;
    width: 36px; height: 4px; border-radius: 2px;
    background: #dfe3e8; margin: 0 auto 6px;
  }
  .pot-item { padding: 10px 8px; }
  .pot-rank { font-size: 13px; }
  .pot-sub { font-size: 11px; }
  .pot-hint { font-size: 12px; padding: 8px 12px; }
  .pot-expand-tip { font-size: 12px; padding: 3px 10px; }
  /* 移动端隐藏 leaflet 自带控件，节省屏幕空间（用双指缩放） */
  .leaflet-control-zoom,
  .leaflet-control-attribution { display: none !important; }
}
