/* ============================================================
   织脉 WeaveMap · 人脉地图 — 样式
   ============================================================ */

/* ---------- 主题变量 ---------- */
:root {
  --primary: #6366f1;
  --primary-strong: #4f46e5;
  --primary-soft: rgba(99, 102, 241, .12);
  --danger: #ef4444;
  --success: #10b981;

  --bg: #f5f6fa;
  --surface: #ffffff;
  --surface-2: #f0f1f7;
  --text: #1e2233;
  --text-2: #5a6072;
  --text-3: #8b91a6;
  --border: #e3e6ef;
  --shadow: 0 10px 30px rgba(15, 20, 45, .10);
  --shadow-sm: 0 2px 10px rgba(15, 20, 45, .08);
  --ring: rgba(99, 102, 241, .35);

  --radius: 16px;
  --radius-sm: 10px;
  --topbar-h: 56px;
  --tabs-h: 46px;
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "Noto Sans SC", sans-serif;
}
html[data-theme="dark"] {
  --bg: #0e1016;
  --surface: #171a23;
  --surface-2: #1f2330;
  --text: #e9ebf3;
  --text-2: #a6acbc;
  --text-3: #6e7589;
  --border: #262b3a;
  --shadow: 0 10px 30px rgba(0, 0, 0, .5);
  --shadow-sm: 0 2px 10px rgba(0, 0, 0, .4);
  --ring: rgba(129, 140, 248, .4);
}

/* ---------- 基础 ---------- */
* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  overflow: hidden;
  -webkit-tap-highlight-color: transparent;
}
[hidden] { display: none !important; }
button { font-family: inherit; cursor: pointer; border: none; background: none; color: inherit; }
input, select, textarea { font-family: inherit; font-size: 15px; color: var(--text); }
::placeholder { color: var(--text-3); }
:focus-visible { outline: 2px solid var(--ring); outline-offset: 2px; border-radius: 6px; }
code { background: var(--surface-2); padding: 1px 6px; border-radius: 6px; font-size: .85em; }

/* ---------- 应用布局 ---------- */
#app {
  height: 100vh;
  height: 100dvh;
  display: flex;
  flex-direction: column;
  max-width: 100%;
}
.topbar {
  height: var(--topbar-h);
  padding: 0 16px;
  padding-top: env(safe-area-inset-top);
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-shrink: 0;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}
.brand { display: flex; align-items: center; gap: 10px; min-width: 0; }
.brand-logo {
  width: 36px; height: 36px; border-radius: 11px;
  background: linear-gradient(135deg, #6366f1, #8b5cf6);
  color: #fff; display: flex; align-items: center; justify-content: center;
  box-shadow: 0 4px 12px rgba(99, 102, 241, .35);
  flex-shrink: 0;
}
.brand-text { line-height: 1.15; min-width: 0; }
.brand-text h1 { font-size: 17px; font-weight: 800; letter-spacing: .5px; }
.brand-sub { font-size: 11px; color: var(--text-3); }
.topbar-actions { display: flex; gap: 6px; }
.icon-btn {
  width: 38px; height: 38px; border-radius: 50%;
  display: inline-flex; align-items: center; justify-content: center;
  color: var(--text-2); background: transparent;
  transition: background .15s, color .15s;
}
.icon-btn:hover { background: var(--surface-2); color: var(--text); }

/* ---------- 视图切换 ---------- */
.view-toggle {
  height: var(--tabs-h);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  flex-shrink: 0;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 0 16px;
}
.view-tab {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 7px 18px; border-radius: 999px;
  font-size: 14px; font-weight: 600; color: var(--text-2);
  transition: all .18s;
}
.view-tab.active {
  background: var(--primary);
  color: #fff;
  box-shadow: 0 4px 12px rgba(99, 102, 241, .35);
}

/* ---------- 视图容器 ---------- */
.view { position: relative; flex: 1; min-height: 0; display: flex; flex-direction: column; }
.view-map { background: var(--surface); }
.view-list { background: var(--bg); }

/* ---------- 分类筛选条 ---------- */
.filter-bar {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  padding: 10px 12px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: relative;
  z-index: 600;
}
.chips {
  display: flex; gap: 8px; overflow-x: auto;
  scrollbar-width: none; padding: 2px;
  flex-wrap: nowrap; cursor: grab;
  scroll-behavior: smooth;
  touch-action: pan-x;
  user-select: none; -webkit-user-select: none;
}
.chips.dragging { cursor: grabbing; scroll-behavior: auto; }
.chips:active { cursor: grabbing; }
.chips::-webkit-scrollbar { display: none; }
.chip {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 6px 13px; border-radius: 999px;
  background: var(--surface-2);
  border: 1px solid transparent;
  font-size: 13px; font-weight: 600; color: var(--text-2);
  white-space: nowrap; flex-shrink: 0;
  transition: all .15s;
}
.chip .dot { width: 9px; height: 9px; border-radius: 50%; background: var(--c, #999); }
.chip .cnt { font-size: 11px; opacity: .7; font-weight: 500; }
.chip:hover { background: var(--border); color: var(--text); }
.chip.active {
  background: var(--primary);
  color: #fff;
  border-color: var(--primary);
  box-shadow: 0 3px 10px rgba(99, 102, 241, .3);
}
.chip.active .dot { background: #fff; }

/* ---------- 地图 ---------- */
.map { flex: 1; min-height: 0; width: 100%; z-index: 1; }
.map-hud {
  position: absolute; right: 14px; bottom: calc(18px + env(safe-area-inset-bottom));
  display: flex; flex-direction: column; gap: 10px; z-index: 500;
}
.hud-btn {
  width: 46px; height: 46px; border-radius: 50%;
  background: var(--surface); color: var(--text);
  display: flex; align-items: center; justify-content: center;
  box-shadow: var(--shadow-sm);
  transition: transform .15s, box-shadow .15s;
  border: 1px solid var(--border);
}
.hud-btn:hover { transform: translateY(-1px); box-shadow: var(--shadow); }
.hud-btn:active { transform: scale(.94); }
.hud-btn-primary {
  background: linear-gradient(135deg, #6366f1, #7c3aed);
  color: #fff; border: none; width: 52px; height: 52px;
  box-shadow: 0 8px 20px rgba(99, 102, 241, .45);
}
.map-hint {
  position: absolute; left: 50%; transform: translateX(-50%);
  bottom: calc(20px + env(safe-area-inset-bottom));
  background: rgba(20, 24, 40, .78); color: #fff;
  padding: 7px 14px; border-radius: 999px;
  font-size: 12.5px; white-space: nowrap; z-index: 500;
  pointer-events: none;
}

/* Leaflet 微调 */
.leaflet-container { background: #dfe3ea; font-family: var(--font); }
html[data-theme="dark"] .leaflet-container { background: #0d0f15; }
.leaflet-bar a {
  background: var(--surface) !important;
  color: var(--text) !important;
  border-color: var(--border) !important;
}
.leaflet-bar a:hover { background: var(--surface-2) !important; }
.leaflet-control-attribution {
  background: rgba(255,255,255,.75) !important;
  color: var(--text-3) !important;
  font-size: 10px !important;
}
html[data-theme="dark"] .leaflet-control-attribution { background: rgba(10,12,18,.75) !important; }
.leaflet-control-attribution a { color: var(--text-3) !important; }
.leaflet-popup-content-wrapper { border-radius: 12px; box-shadow: var(--shadow-sm); }
html[data-theme="dark"] .leaflet-popup-content-wrapper,
html[data-theme="dark"] .leaflet-popup-tip { background: var(--surface); color: var(--text); }

/* 用户位置脉冲点 */
.user-dot {
  width: 16px; height: 16px; border-radius: 50%;
  background: #3b82f6; border: 3px solid #fff;
  box-shadow: 0 0 0 4px rgba(59, 130, 246, .35);
}
.user-pulse {
  position: absolute; left: 50%; top: 50%;
  width: 44px; height: 44px; margin: -22px 0 0 -22px;
  border-radius: 50%; border: 2px solid rgba(59, 130, 246, .55);
  animation: pulse 1.8s ease-out infinite;
  pointer-events: none;
}
@keyframes pulse {
  0% { transform: scale(.45); opacity: 1; }
  100% { transform: scale(1.35); opacity: 0; }
}

/* 地图点击添加气泡 */
.add-prompt { display: flex; flex-direction: column; align-items: center; }
.add-prompt .ap-btn {
  width: 44px; height: 44px; border-radius: 50%;
  background: linear-gradient(135deg, #6366f1, #7c3aed);
  color: #fff; font-size: 26px; line-height: 1; font-weight: 700;
  display: flex; align-items: center; justify-content: center;
  box-shadow: 0 6px 16px rgba(99, 102, 241, .5);
  border: 2px solid #fff;
  cursor: pointer;
  transition: transform .15s;
}
.add-prompt .ap-btn:hover { transform: scale(1.08); }
.add-prompt .ap-btn:active { transform: scale(.92); }
.add-prompt .ap-lbl {
  margin-top: 5px; padding: 3px 11px; border-radius: 999px;
  background: rgba(20, 24, 40, .88); color: #fff;
  font-size: 12px; white-space: nowrap; font-weight: 600;
  box-shadow: 0 2px 8px rgba(0, 0, 0, .3);
}

/* ---------- 列表视图 ---------- */
.list-toolbar {
  flex-shrink: 0;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 10px 14px 12px;
  display: flex; flex-direction: column; gap: 10px;
}
.search-box {
  display: flex; align-items: center; gap: 8px;
  background: var(--surface-2);
  border: 1px solid transparent;
  border-radius: 12px; padding: 9px 12px;
  color: var(--text-3);
  transition: border-color .15s, background .15s;
}
.search-box:focus-within { border-color: var(--primary); background: var(--surface); }
.search-box input {
  flex: 1; border: none; background: transparent; outline: none; min-width: 0;
}
.list-meta {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
}
.list-count { font-size: 12.5px; color: var(--text-3); }
.sort-box {
  display: flex; align-items: center; gap: 6px; font-size: 13px; color: var(--text-3);
}
.sort-box select {
  border: 1px solid var(--border); background: var(--surface);
  border-radius: 8px; padding: 4px 8px; font-size: 13px; outline: none;
  color: var(--text-2);
}
.list {
  flex: 1; overflow-y: auto; padding: 12px 14px calc(20px + env(safe-area-inset-bottom));
  display: flex; flex-direction: column; gap: 10px;
}

/* 人员卡片 */
.person-card {
  display: flex; align-items: center; gap: 12px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px 14px;
  box-shadow: var(--shadow-sm);
  cursor: pointer;
  transition: transform .12s, box-shadow .15s, border-color .15s;
  animation: cardIn .25s ease both;
}
@keyframes cardIn { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
.person-card:hover { transform: translateY(-1px); box-shadow: var(--shadow); border-color: var(--primary); }
.person-card:active { transform: scale(.985); }
.avatar {
  width: 44px; height: 44px; border-radius: 14px; flex-shrink: 0;
  background: var(--c, var(--primary));
  color: #fff; font-size: 18px; font-weight: 700;
  display: flex; align-items: center; justify-content: center;
  box-shadow: 0 3px 8px color-mix(in srgb, var(--c, var(--primary)) 40%, transparent);
}
.pc-main { flex: 1; min-width: 0; }
.pc-row1 { display: flex; align-items: center; gap: 8px; }
.pc-name { font-size: 15.5px; font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.badge {
  flex-shrink: 0; font-size: 11px; font-weight: 700;
  padding: 2px 9px; border-radius: 999px;
  background: color-mix(in srgb, var(--c, var(--primary)) 14%, transparent);
  color: var(--c, var(--primary));
  border: 1px solid color-mix(in srgb, var(--c, var(--primary)) 35%, transparent);
}
.pc-row2 {
  font-size: 12.5px; color: var(--text-2); margin-top: 2px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.pc-row3 {
  font-size: 12px; color: var(--text-3); margin-top: 3px;
  display: flex; align-items: center; gap: 5px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.pc-row3 .dist { color: var(--primary); font-weight: 600; flex-shrink: 0; }
.pc-nav {
  flex-shrink: 0; width: 38px; height: 38px; border-radius: 50%;
  background: var(--primary-soft); color: var(--primary);
  display: flex; align-items: center; justify-content: center;
  font-size: 17px;
  transition: transform .12s;
}
.pc-nav:hover { transform: scale(1.08); }
.pc-nav:active { transform: scale(.92); }
.pc-noloc { color: var(--text-3); font-size: 12px; display: inline-flex; align-items: center; gap: 4px; }

/* 空状态 */
.empty-state {
  flex: 1; display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: 10px;
  padding: 40px 24px; text-align: center; color: var(--text-2);
}
.empty-icon { font-size: 52px; opacity: .8; }
.empty-state p { font-size: 15px; font-weight: 600; }
.empty-actions { display: flex; flex-direction: column; gap: 10px; margin-top: 8px; }

/* ---------- 按钮 ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 11px 20px; border-radius: 12px;
  font-size: 14.5px; font-weight: 700;
  transition: all .15s;
  border: 1px solid transparent;
}
.btn-primary {
  background: linear-gradient(135deg, #6366f1, #7c3aed);
  color: #fff; box-shadow: 0 6px 16px rgba(99, 102, 241, .35);
}
.btn-primary:hover { filter: brightness(1.06); }
.btn-primary:active { transform: scale(.97); }
.btn-ghost {
  background: var(--surface-2); color: var(--text-2);
  border: 1px solid var(--border);
}
.btn-ghost:hover { background: var(--border); color: var(--text); }
.btn-danger-ghost {
  background: transparent; color: var(--danger);
  border: 1px solid color-mix(in srgb, var(--danger) 40%, transparent);
}
.btn-danger-ghost:hover { background: color-mix(in srgb, var(--danger) 10%, transparent); }
.btn-sm { padding: 7px 13px; font-size: 13px; border-radius: 10px; }

/* ---------- 弹层通用 ---------- */
.sheet, .modal { position: fixed; inset: 0; z-index: 900; }
.sheet-backdrop, .modal-backdrop {
  position: absolute; inset: 0;
  background: rgba(10, 13, 25, .45);
  backdrop-filter: blur(2px);
  animation: fadeIn .2s ease;
}
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

/* 底部抽屉（移动端）/ 侧边面板（桌面） */
.sheet-panel {
  position: absolute;
  background: var(--surface);
  border-radius: 20px 20px 0 0;
  box-shadow: var(--shadow);
  animation: sheetUp .28s cubic-bezier(.2, .8, .25, 1);
}
@keyframes sheetUp { from { transform: translateY(40px); opacity: .4; } to { transform: none; opacity: 1; } }
.sheet-handle {
  width: 40px; height: 4px; border-radius: 4px;
  background: var(--border); margin: 8px auto 2px;
  flex-shrink: 0;
}
.detail-sheet .sheet-panel {
  left: 0; right: 0; bottom: 0;
  max-height: 82dvh;
  display: flex; flex-direction: column;
  padding-bottom: env(safe-area-inset-bottom);
}
.form-sheet .sheet-panel {
  left: 0; right: 0; bottom: 0;
  max-height: 94dvh;
  display: flex; flex-direction: column;
  padding-bottom: env(safe-area-inset-bottom);
}

/* ---------- 详情内容 ---------- */
#detail-content { overflow-y: auto; padding: 4px 20px 24px; }
.detail-sheet .sheet-close {
  position: absolute; top: 10px; right: 12px; z-index: 10;
  background: var(--surface-2);
  width: 36px; height: 36px;
}
.detail-sheet .sheet-close:hover { background: var(--border); }
.detail-head { display: flex; gap: 14px; align-items: flex-start; padding: 8px 40px 14px 0; }
.detail-avatar {
  width: 62px; height: 62px; border-radius: 18px; flex-shrink: 0;
  background: var(--c, var(--primary)); color: #fff;
  font-size: 26px; font-weight: 800;
  display: flex; align-items: center; justify-content: center;
  box-shadow: 0 6px 16px color-mix(in srgb, var(--c, var(--primary)) 45%, transparent);
}
.detail-title { min-width: 0; flex: 1; }
.detail-title h3 { font-size: 20px; font-weight: 800; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.detail-title .role { font-size: 13.5px; color: var(--text-2); margin-top: 3px; overflow-wrap: anywhere; }
.detail-rows { display: flex; flex-direction: column; gap: 4px; }
.d-row {
  display: flex; align-items: center; gap: 12px;
  padding: 11px 12px; border-radius: 12px;
  background: var(--surface-2);
  text-decoration: none; color: var(--text);
  transition: background .15s;
}
.d-row:hover { background: var(--border); }
.d-row .d-icon { font-size: 16px; width: 22px; text-align: center; flex-shrink: 0; }
.d-row .d-label { font-size: 11.5px; color: var(--text-3); width: 34px; flex-shrink: 0; }
.d-row .d-val { flex: 1; min-width: 0; font-size: 14px; overflow-wrap: anywhere; }

/* 电话行（复制/拨打） */
.d-phone {
  display: flex; align-items: center; gap: 12px;
  padding: 11px 12px; border-radius: 12px;
  background: var(--surface-2); color: var(--text);
  text-decoration: none; cursor: pointer;
  border: 1px solid transparent;
  transition: border-color .15s, background .15s;
}
.d-phone:hover { background: var(--border); border-color: var(--primary); }
.d-phone .d-icon { font-size: 16px; width: 22px; text-align: center; flex-shrink: 0; }
.d-phone-num {
  flex: 1; min-width: 0; font-size: 14px; font-weight: 700;
  color: var(--primary); font-family: ui-monospace, Consolas, monospace;
  letter-spacing: .3px; overflow-wrap: anywhere;
}
.d-phone-act {
  flex-shrink: 0; font-size: 12.5px; font-weight: 700;
  color: var(--primary); background: var(--primary-soft);
  border-radius: 999px; padding: 5px 13px;
}
.d-note { margin-top: 10px; padding: 12px; border-radius: 12px; background: var(--surface-2); font-size: 13.5px; color: var(--text-2); white-space: pre-wrap; }
.d-coords { margin-top: 8px; font-size: 11.5px; color: var(--text-3); text-align: center; }
.d-actions { display: flex; gap: 10px; margin-top: 16px; flex-wrap: wrap; }
.d-actions .btn { flex: 1; min-width: 110px; }
.d-danger-row { margin-top: 10px; display: flex; justify-content: flex-end; }
.d-link { color: var(--primary); font-size: 13px; font-weight: 600; padding: 6px 8px; }
.d-section-title { margin: 14px 0 8px; font-size: 12.5px; font-weight: 700; color: var(--text-3); }
.d-addrs { display: flex; flex-direction: column; gap: 8px; margin-bottom: 6px; }
.d-addr { padding: 11px 12px; border-radius: 12px; background: var(--surface-2); }
.d-addr-head { display: flex; align-items: center; gap: 8px; }
.d-addr-head .badge { flex-shrink: 0; }
.d-addr-dist { font-size: 12px; color: var(--primary); font-weight: 700; }
.d-addr-status { margin-left: auto; font-size: 11.5px; color: var(--success); font-weight: 600; white-space: nowrap; flex-shrink: 0; }
.d-addr-status.noloc { color: var(--text-3); }
.d-addr-text { margin-top: 5px; font-size: 13.5px; color: var(--text); overflow-wrap: anywhere; }
.d-addr-nav { margin-top: 8px; }

/* ---------- 表单 ---------- */
.form-sheet form {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
}
.form-sheet .sheet-head, .form-sheet .sheet-foot { flex-shrink: 0; }
.form-body { overflow-y: auto; padding: 6px 20px 16px; flex: 1; min-height: 55vh; }
.sheet-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 20px 12px; flex-shrink: 0;
}
.sheet-head h2, .modal-head h2 { font-size: 17px; font-weight: 800; }
.sheet-foot {
  display: flex; gap: 12px; padding: 12px 20px calc(14px + env(safe-area-inset-bottom));
  border-top: 1px solid var(--border); flex-shrink: 0;
}
.sheet-foot .btn { flex: 1; }
.field { margin-bottom: 14px; }
.field > label { display: block; font-size: 13px; font-weight: 700; color: var(--text-2); margin-bottom: 6px; }
.field label em { color: var(--danger); font-style: normal; }
.field input[type="text"], .field input[type="tel"], .field input[type="search"], .field textarea, .field select {
  width: 100%; padding: 11px 13px;
  border: 1px solid var(--border); border-radius: 12px;
  background: var(--surface-2);
  outline: none; transition: border-color .15s, background .15s;
}
.field input:focus, .field textarea:focus, .field select:focus {
  border-color: var(--primary); background: var(--surface);
}
.field textarea { resize: vertical; min-height: 56px; }
.field-row { display: flex; gap: 12px; }
.field-row .field { flex: 1; min-width: 0; }
.select-wrap { position: relative; }
.select-wrap::after {
  content: "▾"; position: absolute; right: 14px; top: 50%;
  transform: translateY(-50%); color: var(--text-3); pointer-events: none; font-size: 13px;
}
.select-wrap select { appearance: none; -webkit-appearance: none; padding-right: 34px; }
.field-hint { font-size: 12px; color: var(--text-3); margin-top: 5px; line-height: 1.5; }

/* 选点地图 */
.picker-search { display: flex; gap: 8px; margin-bottom: 8px; }
.picker-search input { flex: 1; }
.picker-results {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 12px; margin-bottom: 8px; overflow: hidden;
  box-shadow: var(--shadow-sm);
}
.picker-results .pr-item { padding: 9px 13px; font-size: 13px; cursor: pointer; border-bottom: 1px solid var(--border); }
.picker-results .pr-item:last-child { border-bottom: none; }
.picker-results .pr-item:hover { background: var(--primary-soft); color: var(--primary); }
.picker-map { height: 420px; border-radius: 14px; border: 1px solid var(--border); overflow: hidden; z-index: 1; }
.picker-tools { display: flex; gap: 8px; margin-top: 8px; flex-wrap: wrap; }
.picker-coords { margin-top: 8px; font-size: 12px; color: var(--text-3); font-family: ui-monospace, Consolas, monospace; }
.picker-target { font-weight: 600; color: var(--primary); }

/* 地址列表（表单） */
.addr-list { display: flex; flex-direction: column; gap: 8px; margin-bottom: 8px; }
.addr-item {
  border: 1px solid var(--border); border-radius: 12px;
  padding: 10px 12px; background: var(--surface-2);
  cursor: pointer; transition: border-color .15s, background .15s;
}
.addr-item.active { border-color: var(--primary); background: var(--primary-soft); }
.addr-head { display: flex; align-items: center; gap: 8px; }
.addr-label {
  width: 96px; padding: 6px 26px 6px 9px; border: 1px solid var(--border); border-radius: 9px;
  background: var(--surface); font-size: 13px; font-weight: 600; outline: none;
  appearance: none; -webkit-appearance: none; cursor: pointer;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%238b91a6' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 8px center;
}
.addr-label:focus { border-color: var(--primary); }
.addr-status { font-size: 12px; color: var(--success); font-weight: 600; white-space: nowrap; flex-shrink: 0; }
.addr-status.noloc { color: var(--text-3); }
.addr-del {
  margin-left: auto; width: 26px; height: 26px; border-radius: 50%;
  color: var(--text-3); font-size: 13px; display: inline-flex; align-items: center; justify-content: center;
  background: transparent; transition: background .15s, color .15s;
}
.addr-del:hover { background: color-mix(in srgb, var(--danger) 12%, transparent); color: var(--danger); }
.addr-text {
  margin-top: 8px; width: 100%; padding: 9px 11px; border: 1px solid var(--border); border-radius: 10px;
  background: var(--surface); font-size: 13.5px; outline: none;
}
.addr-text:focus { border-color: var(--primary); }

/* ---------- 模态框 ---------- */
.modal-card {
  position: absolute; left: 50%; top: 50%;
  transform: translate(-50%, -50%);
  width: min(500px, calc(100vw - 32px));
  max-height: 86dvh;
  background: var(--surface);
  border-radius: 20px;
  box-shadow: var(--shadow);
  display: flex; flex-direction: column;
  animation: modalIn .22s cubic-bezier(.2, .8, .25, 1);
}
@keyframes modalIn { from { opacity: 0; transform: translate(-50%, -46%) scale(.96); } to { opacity: 1; transform: translate(-50%, -50%) scale(1); } }
.modal-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 20px 12px; flex-shrink: 0;
}
.modal-head h2 span { color: var(--primary); }
.modal-body { overflow-y: auto; padding: 4px 20px 22px; }

/* 确认弹窗 */
.confirm-card { width: min(360px, calc(100vw - 32px)); }
.confirm-msg {
  font-size: 14.5px; color: var(--text); line-height: 1.7;
  padding: 6px 2px 14px; overflow-wrap: anywhere;
}
.confirm-msg .confirm-name {
  color: var(--danger); font-weight: 800;
}
.confirm-actions { display: flex; gap: 10px; justify-content: flex-end; }
.confirm-actions .btn { min-width: 92px; }
.btn-danger {
  background: var(--danger); color: #fff;
  border: 1px solid transparent;
  box-shadow: 0 4px 14px color-mix(in srgb, var(--danger) 40%, transparent);
}
.btn-danger:hover { filter: brightness(1.07); }

/* 导航弹窗 */
.mode-row { display: flex; gap: 8px; margin-bottom: 14px; flex-wrap: wrap; }
.mode-btn {
  padding: 8px 14px; border-radius: 999px;
  background: var(--surface-2); color: var(--text-2);
  font-size: 13.5px; font-weight: 600;
  border: 1px solid transparent;
  transition: all .15s;
}
.mode-btn.active { background: var(--primary); color: #fff; box-shadow: 0 4px 12px rgba(99, 102, 241, .35); }
.nav-options { display: flex; flex-direction: column; gap: 9px; }
.nav-opt {
  display: flex; align-items: center; gap: 12px;
  padding: 12px 14px; border-radius: 14px;
  border: 1px solid var(--border); background: var(--surface);
  text-decoration: none; color: var(--text);
  transition: all .15s;
}
.nav-opt:hover { border-color: var(--primary); box-shadow: var(--shadow-sm); transform: translateY(-1px); }
.nav-opt .n-icon { font-size: 22px; width: 34px; text-align: center; }
.nav-opt .n-name { font-weight: 700; font-size: 14.5px; }
.nav-opt .n-desc { font-size: 12px; color: var(--text-3); margin-top: 1px; }
.nav-opt .n-go { margin-left: auto; color: var(--text-3); font-size: 16px; }

/* 分类管理 */
.cat-list { display: flex; flex-direction: column; gap: 8px; margin-bottom: 14px; }
.cat-row {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 12px; border-radius: 12px;
  background: var(--surface-2);
}
.cat-row .cat-color { width: 30px; height: 30px; border-radius: 9px; border: none; padding: 0; background: transparent; cursor: pointer; flex-shrink: 0; }
.cat-row .cat-color::-webkit-color-swatch-wrapper { padding: 0; }
.cat-row .cat-color::-webkit-color-swatch { border-radius: 9px; border: 2px solid #fff; box-shadow: 0 0 0 1px var(--border); }
.cat-row .cat-color::-moz-color-swatch { border-radius: 9px; border: 2px solid #fff; }
.cat-row .cat-name { flex: 1; font-weight: 700; font-size: 14.5px; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cat-row .cat-count { font-size: 12px; color: var(--text-3); flex-shrink: 0; }
.cat-row .cat-del { color: var(--text-3); padding: 6px; border-radius: 8px; flex-shrink: 0; }
.cat-row .cat-del:hover { color: var(--danger); background: color-mix(in srgb, var(--danger) 10%, transparent); }
.cat-row.cat-locked .cat-del { visibility: hidden; }
.cat-add { display: flex; gap: 8px; }
.cat-add input { flex: 1; padding: 10px 13px; border: 1px solid var(--border); border-radius: 12px; background: var(--surface-2); outline: none; }
.cat-add input:focus { border-color: var(--primary); background: var(--surface); }

/* 设置 */
.set-group { margin-bottom: 20px; }
.set-group h3 { font-size: 13px; color: var(--text-3); font-weight: 700; margin-bottom: 10px; }
.tile-options { display: flex; flex-wrap: wrap; gap: 8px; }
.tile-opt {
  padding: 8px 14px; border-radius: 999px;
  background: var(--surface-2); border: 1px solid var(--border);
  font-size: 13px; font-weight: 600; color: var(--text-2);
  transition: all .15s;
}
.tile-opt.active { background: var(--primary); color: #fff; border-color: var(--primary); }
.seg { display: flex; gap: 8px; }
.seg-btn {
  flex: 1; padding: 9px 6px; border-radius: 12px;
  background: var(--surface-2); border: 1px solid transparent;
  font-size: 13px; font-weight: 600; color: var(--text-2);
  transition: all .15s;
}
.seg-btn.active { background: var(--primary); color: #fff; }
.set-btns { display: grid; grid-template-columns: 1fr 1fr; gap: 9px; }
.set-btns .btn { width: 100%; }
.tips { padding-left: 18px; display: flex; flex-direction: column; gap: 6px; font-size: 13px; color: var(--text-2); }
.about-line { text-align: center; font-size: 12px; color: var(--text-3); margin-top: 4px; }

/* ---------- Toast ---------- */
.toast {
  position: fixed; left: 50%; bottom: calc(28px + env(safe-area-inset-bottom));
  transform: translateX(-50%) translateY(20px);
  background: rgba(24, 28, 45, .92); color: #fff;
  padding: 10px 20px; border-radius: 999px;
  font-size: 13.5px; font-weight: 600;
  box-shadow: var(--shadow); z-index: 1200;
  opacity: 0; pointer-events: none;
  transition: all .25s ease;
  max-width: min(88vw, 420px); text-align: center;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ============================================================
   桌面端：左右分栏（列表 + 地图）
   ============================================================ */
@media (min-width: 880px) {
  #app {
    display: grid;
    grid-template-columns: 400px 1fr;
    grid-template-rows: var(--topbar-h) 1fr;
  }
  .topbar { grid-column: 1 / -1; grid-row: 1; }
  .view-toggle { display: none; }
  #view-list { grid-column: 1; grid-row: 2; display: flex; border-right: 1px solid var(--border); }
  #view-map { grid-column: 2; grid-row: 2; display: flex; }
  #view-list[hidden] { display: flex !important; }
  #view-map[hidden] { display: flex !important; }
  .list { padding-bottom: 20px; }
  .filter-bar { display: none; } /* 桌面端分类筛选统一在列表侧 */
  .map-hint { bottom: 20px; }

  /* 详情面板：右侧浮层 */
  .detail-sheet .sheet-panel {
    left: auto; right: 18px; bottom: 18px; top: 18px;
    width: 390px; max-height: none;
    border-radius: 20px;
    animation: panelIn .25s cubic-bezier(.2, .8, .25, 1);
    padding-bottom: 0;
  }
  @keyframes panelIn { from { transform: translateX(30px); opacity: .3; } to { transform: none; opacity: 1; } }
  .detail-sheet .sheet-handle { display: none; }
  .detail-sheet .sheet-backdrop { background: transparent; }

  /* 表单：居中卡片 */
  .form-sheet .sheet-panel {
    left: 50%; right: auto; top: 50%; bottom: auto;
    transform: translate(-50%, -50%);
    width: min(620px, calc(100vw - 60px));
    max-height: 90dvh;
    border-radius: 20px;
    animation: modalIn .22s cubic-bezier(.2, .8, .25, 1);
  }
  .form-sheet .sheet-handle { display: none; }
  .picker-map { height: 480px; }
}

/* 小屏微调 */
@media (max-width: 380px) {
  .field-row { flex-direction: column; gap: 0; }
  .brand-sub { display: none; }
}

/* ---------- 登录界面 ---------- */
.login-overlay {
  position: fixed; inset: 0; z-index: 2000;
  display: flex; align-items: center; justify-content: center;
  background: linear-gradient(135deg, #4f46e5 0%, #7c3aed 45%, #c026d3 100%);
  padding: 24px;
}
.login-card {
  width: 380px; max-width: 100%;
  background: var(--surface); border-radius: 22px;
  padding: 34px 30px 28px; box-shadow: 0 24px 60px rgba(0, 0, 0, .3);
  text-align: center;
}
.login-logo {
  width: 60px; height: 60px; margin: 0 auto 14px; border-radius: 16px;
  background: linear-gradient(135deg, #6366f1, #8b5cf6); color: #fff;
  display: flex; align-items: center; justify-content: center;
  box-shadow: 0 8px 20px rgba(99, 102, 241, .4);
}
.login-card h1 { font-size: 20px; font-weight: 800; color: var(--text); }
.login-sub { color: var(--text-3); font-size: 13px; margin: 4px 0 22px; }
.login-field { margin-bottom: 12px; }
.login-field input {
  width: 100%; padding: 13px 15px; border: 1px solid var(--border);
  border-radius: 12px; background: var(--surface-2); font-size: 15px; outline: none; color: var(--text);
}
.login-field input:focus { border-color: var(--primary); background: var(--surface); }
.captcha-row { display: flex; gap: 10px; align-items: center; }
.captcha-row input { flex: 1; }
.captcha-row img {
  height: 44px; border-radius: 10px; cursor: pointer; flex-shrink: 0;
  border: 1px solid var(--border);
}
.login-remember { display: flex; justify-content: center; margin: 4px 0 16px; font-size: 13px; color: var(--text-2); }
.remember-box { display: flex; align-items: center; gap: 6px; cursor: pointer; user-select: none; }
.remember-box input { width: 16px; height: 16px; accent-color: var(--primary); cursor: pointer; }
.login-alt {
  display: flex; align-items: center; justify-content: center; gap: 6px;
  margin-top: 16px; font-size: 13.5px; color: var(--text-3);
}
.link-btn {
  border: none; background: none; color: var(--primary);
  font-size: 13.5px; font-weight: 700; cursor: pointer; padding: 2px 4px;
}
.link-btn:hover { text-decoration: underline; }
.login-btn {
  width: 100%; padding: 13px; border-radius: 12px; border: none;
  background: linear-gradient(135deg, #6366f1, #7c3aed); color: #fff;
  font-size: 15px; font-weight: 700; cursor: pointer;
  box-shadow: 0 6px 16px rgba(99, 102, 241, .35);
  transition: filter .15s;
}
.login-btn:hover { filter: brightness(1.06); }
.login-error { margin-top: 12px; color: var(--danger); font-size: 13px; font-weight: 600; }
.login-success {
  margin-top: 14px;
  display: flex; align-items: center; justify-content: center; gap: 8px;
  padding: 12px 14px;
  border-radius: 12px;
  background: color-mix(in srgb, var(--success) 12%, transparent);
  border: 1px solid color-mix(in srgb, var(--success) 45%, transparent);
  color: var(--success);
  font-size: 14px; font-weight: 700;
  animation: successIn .35s cubic-bezier(.2, .8, .25, 1);
  box-shadow: 0 4px 14px color-mix(in srgb, var(--success) 18%, transparent);
}
@keyframes successIn { from { opacity: 0; transform: translateY(6px) scale(.97); } to { opacity: 1; transform: none; } }
.login-success .ls-icon {
  width: 22px; height: 22px; border-radius: 50%; flex-shrink: 0;
  background: var(--success); color: #fff;
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 13px; font-weight: 800;
}
.migrate-box {
  margin-top: 18px; padding: 12px; border: 1px dashed var(--border);
  border-radius: 12px; background: var(--surface-2);
}
.migrate-box p { font-size: 12.5px; color: var(--text-2); margin-bottom: 8px; }

/* 顶栏当前用户 + 账户菜单 */
.current-user {
  font-size: 13px; font-weight: 600; color: var(--text-2);
  margin-right: 4px; padding: 6px 10px; border-radius: 8px;
  background: var(--surface-2); max-width: 130px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  cursor: pointer; transition: background .15s, color .15s;
}
.current-user:hover { background: var(--border); color: var(--text); }
.user-menu-wrap { position: relative; }
.user-menu {
  position: absolute; right: 4px; top: calc(100% + 6px); z-index: 1000;
  min-width: 150px; background: var(--surface); border: 1px solid var(--border);
  border-radius: 12px; box-shadow: var(--shadow); overflow: hidden;
  animation: modalIn .15s cubic-bezier(.2, .8, .25, 1);
}
.user-menu-head {
  padding: 10px 14px; font-size: 13px; color: var(--text-3);
  border-bottom: 1px solid var(--border); font-weight: 700;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.user-menu-item {
  display: block; width: 100%; text-align: left;
  padding: 11px 14px; font-size: 13.5px; font-weight: 600; color: var(--text-2);
  background: none; border: none; cursor: pointer;
  transition: background .12s, color .12s;
}
.user-menu-item:hover { background: var(--surface-2); color: var(--text); }
.user-menu-item + .user-menu-item { border-top: 1px solid var(--border); }
.set-account-line { font-size: 14px; color: var(--text-2); display: flex; align-items: center; gap: 6px; }
.set-account-line strong { color: var(--primary); }

/* ---------- 名片/图片识别 ---------- */
.ocr-loading { font-size: 13px; color: var(--primary); margin-top: 8px; }
.ocr-preview {
  margin-top: 8px; padding: 12px; border: 1px solid var(--primary);
  border-radius: 12px; background: var(--primary-soft);
}
.ocr-preview-head {
  display: flex; align-items: center; justify-content: space-between;
  font-size: 12.5px; font-weight: 700; color: var(--primary); margin-bottom: 8px;
}
.ocr-preview-head .x-btn { width: 24px; height: 24px; font-size: 13px; }
.ocr-preview-body { display: flex; flex-direction: column; gap: 4px; margin-bottom: 8px; }
.ocr-row { display: flex; gap: 8px; font-size: 13.5px; align-items: baseline; }
.ocr-row .k { flex-shrink: 0; width: 40px; color: var(--text-3); font-size: 12px; }
.ocr-row .v { flex: 1; color: var(--text); word-break: break-all; }
.ocr-preview-actions { display: flex; justify-content: flex-end; gap: 8px; }

/* ---------- 表单选项卡 ---------- */
.form-tabs { display: flex; border-bottom: 1px solid var(--border); flex-shrink: 0; background: var(--surface-2); }
.form-tab {
  flex: 1; padding: 12px 4px; text-align: center;
  font-size: 14px; font-weight: 600; color: var(--text-2);
  border-bottom: 2px solid transparent; cursor: pointer;
  transition: color .15s, border-color .15s;
}
.form-tab.active { color: var(--primary); border-bottom-color: var(--primary); background: var(--surface); }
.form-panel { animation: fadeIn .2s ease; }

/* 表单选项卡：居中内容布局（名片识别 / Excel 导入） */
.tab-center {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  text-align: center; min-height: 46vh; padding: 18px 6px 8px;
}
.tab-center .field-hint { max-width: 380px; }
.tab-upload-zone {
  width: min(320px, 100%);
  border: 2px dashed var(--border);
  border-radius: 18px;
  padding: 30px 18px;
  display: flex; flex-direction: column; align-items: center; gap: 8px;
  cursor: pointer; transition: all .18s;
  background: var(--surface-2);
}
.tab-upload-zone:hover { border-color: var(--primary); background: var(--primary-soft); }
.tab-upload-zone:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }
.tab-upload-zone .tu-icon { font-size: 40px; line-height: 1; filter: drop-shadow(0 4px 10px rgba(99,102,241,.35)); }
.tab-upload-zone .tu-title { font-size: 15.5px; font-weight: 800; color: var(--text); }
.tab-upload-zone .tu-sub { font-size: 12.5px; color: var(--text-3); }
.tab-actions { display: flex; gap: 10px; margin: 14px 0 6px; flex-wrap: wrap; justify-content: center; }
.tab-center .ocr-preview { width: min(380px, 100%); text-align: left; }

/* 分类拖拽 */
.cat-drag { cursor: grab; color: var(--text-3); font-size: 15px; padding: 0 2px; flex-shrink: 0; user-select: none; }
.cat-drag.disabled { cursor: default; opacity: .3; }
.cat-row[draggable="true"] { cursor: default; }
.cat-row.dragging { opacity: .5; }
.set-sub { font-size: 12px; font-weight: 400; color: var(--text-3); }
