/* 智能客户管理系统 - H5 前端样式 */
:root {
  --bg: #f4f6fa;
  --card: #ffffff;
  --text: #1d2129;
  --text-2: #4e5969;
  --muted: #86909c;
  --border: #e5e8ef;
  --brand: #1f5eff;
  --brand-soft: #eaf0ff;
  --red: #e53935;
  --red-soft: #fdecec;
  --green: #12b76a;
  --gold: #c78a1b;
  --gold-soft: #fdf4e3;
  --radius: 12px;
  --shadow: 0 2px 10px rgba(15, 23, 42, 0.06);
  --shadow-lg: 0 8px 28px rgba(15, 23, 42, 0.14);
}

* { box-sizing: border-box; }

/* 带 hidden 属性的元素必须隐藏，避免被 display:flex/grid 覆盖 */
[hidden] { display: none !important; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Hiragino Sans GB",
    "Microsoft YaHei", "Helvetica Neue", Arial, sans-serif;
  font-size: 15px;
  line-height: 1.6;
  -webkit-tap-highlight-color: transparent;
}

a { color: var(--brand); text-decoration: none; }
button { font-family: inherit; }

/* ---------- 顶栏 ---------- */
.app-header {
  position: sticky;
  top: 0;
  z-index: 50;
  background: #fff;
  border-bottom: 1px solid var(--border);
  padding: 10px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.app-header .brand {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 700;
  font-size: 16px;
  color: var(--text);
  min-width: 0;
}
.app-header .brand .logo {
  width: 26px;
  height: 26px;
  border-radius: 7px;
  background: linear-gradient(135deg, var(--brand), #5b8cff);
  color: #fff;
  display: grid;
  place-items: center;
  font-size: 14px;
  flex: none;
}
.app-header .brand span.title {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.header-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: none;
}
.user-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 10px;
  border-radius: 999px;
  background: var(--bg);
  font-size: 13px;
  color: var(--text-2);
  max-width: 46vw;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.user-chip .dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--muted);
  flex: none;
}
.user-chip.partner .dot { background: var(--green); }
.user-chip.vip .dot { background: var(--gold); }

/* ---------- 通用元素 ---------- */
.page {
  max-width: 1180px;
  margin: 0 auto;
  padding: 14px 14px 40px;
}
.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 14px;
}
.section-title {
  font-size: 16px;
  font-weight: 700;
  margin: 0 0 10px;
  display: flex;
  align-items: center;
  gap: 8px;
}
.muted { color: var(--muted); }
.small { font-size: 13px; }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  border: 1px solid transparent;
  border-radius: 9px;
  padding: 8px 14px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  background: var(--brand);
  color: #fff;
  transition: opacity 0.15s, transform 0.05s;
  white-space: nowrap;
}
.btn:hover { opacity: 0.92; }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: 0.55; cursor: not-allowed; }
.btn.ghost {
  background: #fff;
  color: var(--text-2);
  border-color: var(--border);
}
.btn.soft { background: var(--brand-soft); color: var(--brand); }
.btn.danger { background: var(--red-soft); color: var(--red); }
.btn.sm { padding: 5px 10px; font-size: 13px; border-radius: 7px; }
.btn.block { width: 100%; }

.tag {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 6px;
  font-size: 12px;
  background: var(--brand-soft);
  color: var(--brand);
  font-weight: 600;
}
.tag.gray { background: #f2f3f5; color: var(--text-2); }
.tag.gold { background: var(--gold-soft); color: var(--gold); }
.tag.green { background: #e8f8f0; color: var(--green); }
.tag.red { background: var(--red-soft); color: var(--red); }

.empty {
  text-align: center;
  padding: 36px 12px;
  color: var(--muted);
}

input[type="text"], input[type="password"], input[type="tel"], input[type="number"],
input[type="search"], select, textarea {
  width: 100%;
  padding: 9px 11px;
  border: 1px solid var(--border);
  border-radius: 9px;
  background: #fff;
  font-size: 14px;
  color: var(--text);
  font-family: inherit;
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}
input:focus, select:focus, textarea:focus {
  border-color: var(--brand);
  box-shadow: 0 0 0 3px rgba(31, 94, 255, 0.12);
}
textarea { resize: vertical; min-height: 92px; }
label.field { display: block; margin-bottom: 12px; }
label.field > span.label-text {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-2);
  margin-bottom: 5px;
}
label.field .req { color: var(--red); margin-left: 2px; }

/* ---------- 主页：地图 ---------- */
.hero {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 10px;
}
.hero h1 { font-size: 19px; margin: 0; }
.hero p { margin: 2px 0 0; color: var(--muted); font-size: 13px; }

.filters {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin-bottom: 10px;
}
.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  flex: 1 1 auto;
  min-width: 0;
}
.chip {
  border: 1px solid var(--border);
  background: #fff;
  color: var(--text-2);
  border-radius: 999px;
  padding: 5px 12px;
  font-size: 13px;
  cursor: pointer;
  font-weight: 600;
}
.chip.active {
  background: var(--brand);
  border-color: var(--brand);
  color: #fff;
}
.search-box {
  display: flex;
  gap: 6px;
  flex: 0 1 260px;
}
.search-box input { padding: 7px 11px; }

.layout {
  display: grid;
  grid-template-columns: 1fr;
  gap: 12px;
}
.map-wrap {
  position: relative;
  background: #eef2f8;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow);
}
#map { width: 100%; height: 58vh; min-height: 340px; }
.map-legend {
  position: absolute;
  left: 10px;
  bottom: 10px;
  background: rgba(255, 255, 255, 0.92);
  border-radius: 8px;
  padding: 5px 9px;
  font-size: 12px;
  color: var(--text-2);
  display: flex;
  align-items: center;
  gap: 6px;
  box-shadow: var(--shadow);
}
.map-legend i {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--red);
  display: inline-block;
  box-shadow: 0 0 0 4px rgba(229, 57, 53, 0.18);
}
.map-notice {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  background: linear-gradient(180deg, #f7f9fc, #eef2f8);
  padding: 20px;
  text-align: center;
  color: var(--text-2);
  font-size: 14px;
}
.map-notice .inner { max-width: 420px; }
.map-notice code {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 5px;
  padding: 1px 5px;
  font-size: 12px;
}
.map-popup {
  position: absolute;
  left: 10px;
  right: 10px;
  bottom: 10px;
  background: #fff;
  border-radius: 12px;
  box-shadow: var(--shadow-lg);
  padding: 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  z-index: 5;
}
.map-popup .info { min-width: 0; }
.map-popup .name { font-weight: 700; font-size: 16px; }
.map-popup .sub { font-size: 13px; color: var(--muted); }

.city-panel { display: flex; flex-direction: column; gap: 8px; min-width: 0; }
.city-panel .panel-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
}
.city-list { display: flex; flex-direction: column; gap: 8px; max-height: 58vh; overflow: auto; padding-right: 2px; }
.load-status {
  text-align: center;
  font-size: 12px;
  color: var(--muted);
  padding: 8px 0 2px;
  letter-spacing: 0.3px;
}
.city-item {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 11px;
  padding: 11px 12px;
  cursor: pointer;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.city-item:hover { border-color: var(--brand); box-shadow: var(--shadow); }
.city-item .row1 {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}
.city-item .city-name { font-weight: 700; font-size: 15px; }
.city-item .count { font-size: 12px; color: var(--muted); flex: none; }
.city-item .tags { margin-top: 6px; display: flex; flex-wrap: wrap; gap: 5px; }
.city-item .customers {
  margin-top: 6px;
  font-size: 12px;
  color: var(--muted);
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}

/* ---------- 城市详情 ---------- */
.breadcrumb { font-size: 13px; color: var(--muted); margin-bottom: 8px; }
.breadcrumb a { color: var(--text-2); }
.city-hero {
  background: linear-gradient(135deg, #1f5eff, #4f86ff);
  color: #fff;
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 12px;
}
.city-hero h1 { margin: 0; font-size: 21px; }
.city-hero p { margin: 4px 0 0; opacity: 0.9; font-size: 13px; }

.customer-card { margin-bottom: 12px; }
.customer-card .head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 8px;
}
.customer-card .name { font-size: 16px; font-weight: 700; }
.customer-card .case {
  margin-top: 10px;
  padding: 10px 12px;
  background: #f8fafd;
  border: 1px solid var(--border);
  border-radius: 10px;
}
.customer-card .case h4 { margin: 0 0 4px; font-size: 14px; }
.customer-card .case p { margin: 0; font-size: 13px; color: var(--text-2); }
.case-images {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
  gap: 8px;
  margin-top: 10px;
}
.case-images figure { margin: 0; }
.case-images img {
  width: 100%;
  height: 92px;
  object-fit: cover;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: #f2f4f8;
  cursor: zoom-in;
}
.case-images figcaption { font-size: 12px; color: var(--muted); margin-top: 3px; }

.doc-list { display: flex; flex-direction: column; gap: 8px; }
.doc-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: #fff;
}
.doc-item .icon {
  width: 38px;
  height: 38px;
  border-radius: 9px;
  background: var(--brand-soft);
  color: var(--brand);
  display: grid;
  place-items: center;
  font-size: 12px;
  font-weight: 700;
  flex: none;
}
.doc-item .icon.draw { background: var(--gold-soft); color: var(--gold); }
.doc-item .meta { min-width: 0; flex: 1; }
.doc-item .title {
  font-weight: 600;
  font-size: 14px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.doc-item .sub { font-size: 12px; color: var(--muted); }
.doc-item .ops { display: flex; gap: 6px; flex: none; }

.locked-card {
  text-align: center;
  padding: 24px 16px;
  border: 1px dashed #d9dee8;
  border-radius: var(--radius);
  background: #fbfcfe;
}
.locked-card .lock-icon {
  width: 52px;
  height: 52px;
  border-radius: 50%;
  background: var(--red-soft);
  color: var(--red);
  display: grid;
  place-items: center;
  margin: 0 auto 10px;
  font-size: 22px;
}
.locked-card h3 { margin: 0 0 6px; font-size: 17px; }
.locked-card p { margin: 0 0 14px; color: var(--muted); font-size: 13px; }
.locked-card .actions { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; }

.wecom-card {
  display: flex;
  align-items: center;
  gap: 12px;
  background: #f6fbf8;
  border: 1px solid #d8efe2;
  border-radius: var(--radius);
  padding: 12px;
}
.wecom-card img {
  width: 86px;
  height: 86px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: #fff;
  object-fit: contain;
  flex: none;
}
.wecom-card .info { min-width: 0; }
.wecom-card .title { font-weight: 700; }
.wecom-card .sub { font-size: 13px; color: var(--text-2); margin: 3px 0 8px; }

/* ---------- 表单页 / 登录页 ---------- */
.narrow { max-width: 520px; margin: 0 auto; }
.form-card { padding: 18px; }
.form-card h1 { font-size: 19px; margin: 0 0 4px; }
.form-card .lead { color: var(--muted); font-size: 13px; margin: 0 0 16px; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }

.tabs { display: flex; gap: 6px; margin-bottom: 14px; background: var(--bg); padding: 4px; border-radius: 10px; }
.tab {
  flex: 1;
  text-align: center;
  padding: 7px 6px;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-2);
  border-radius: 8px;
  cursor: pointer;
  border: none;
  background: transparent;
}
.tab.active { background: #fff; color: var(--brand); box-shadow: var(--shadow); }

.success-box { text-align: center; padding: 10px 4px; }
.success-box .ok-icon {
  width: 54px;
  height: 54px;
  border-radius: 50%;
  background: #e8f8f0;
  color: var(--green);
  display: grid;
  place-items: center;
  font-size: 26px;
  margin: 0 auto 10px;
}

.hint-box {
  background: var(--bg);
  border-radius: 9px;
  padding: 9px 11px;
  font-size: 12px;
  color: var(--muted);
}

/* ---------- 弹层 ---------- */
.modal-mask {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.55);
  z-index: 100;
  display: grid;
  place-items: center;
  padding: 14px;
}
.modal {
  background: #fff;
  border-radius: 14px;
  width: 100%;
  max-width: 560px;
  max-height: 90vh;
  overflow: auto;
  box-shadow: var(--shadow-lg);
}
.modal .modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 13px 15px;
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  background: #fff;
  z-index: 2;
}
.modal .modal-head h3 { margin: 0; font-size: 16px; }
.modal .modal-body { padding: 15px; }
.modal .modal-foot {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  padding: 12px 15px;
  border-top: 1px solid var(--border);
}
.modal .close {
  border: none;
  background: transparent;
  font-size: 20px;
  line-height: 1;
  color: var(--muted);
  cursor: pointer;
}
.viewer {
  background: #0f172a;
  border-radius: 10px;
  overflow: hidden;
  min-height: 300px;
}
.viewer img { width: 100%; display: block; }
.viewer iframe { width: 100%; height: 70vh; border: 0; display: block; background: #fff; }

.toast-wrap {
  position: fixed;
  left: 50%;
  top: 16px;
  transform: translateX(-50%);
  z-index: 200;
  display: flex;
  flex-direction: column;
  gap: 8px;
  width: min(90vw, 420px);
  pointer-events: none;
}
.toast {
  background: #1d2129;
  color: #fff;
  padding: 10px 14px;
  border-radius: 10px;
  font-size: 14px;
  box-shadow: var(--shadow-lg);
  animation: toast-in 0.18s ease-out;
}
.toast.error { background: #c62828; }
.toast.success { background: #1b8a55; }
@keyframes toast-in {
  from { opacity: 0; transform: translateY(-8px); }
  to { opacity: 1; transform: translateY(0); }
}

.spinner {
  width: 22px;
  height: 22px;
  border: 3px solid #dfe5ee;
  border-top-color: var(--brand);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  margin: 24px auto;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- 卡片美化 ---------- */
.card {
  border-color: #e6eaf2;
  border-radius: 16px;
  box-shadow: 0 4px 18px rgba(15, 23, 42, 0.05);
}
.section-title {
  position: relative;
  padding-left: 11px;
}
.section-title::before {
  content: "";
  position: absolute;
  left: 0;
  top: 4px;
  bottom: 4px;
  width: 3px;
  border-radius: 2px;
  background: var(--brand);
}

/* 首页城市卡片 */
.city-item {
  position: relative;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  justify-content: center;
  border-color: #e6eaf2;
  border-radius: 13px;
  padding: 11px 14px;
  min-height: 96px;
  background: #fff;
  transition: border-color 0.2s, box-shadow 0.2s, background 0.2s, transform 0.2s;
  box-shadow: 0 2px 8px rgba(15, 23, 42, 0.035);
}
.city-item::before {
  content: "";
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 3px;
  background: linear-gradient(180deg, #4f86ff, var(--brand));
  opacity: 0;
  transition: opacity 0.15s;
}
.city-item:hover {
  transform: translateY(-3px);
  background: linear-gradient(135deg, #f5f8ff, #eef3ff);
  border-color: #a9c2ff;
  box-shadow: 0 12px 28px rgba(31, 94, 255, 0.18), 0 0 0 1px rgba(31, 94, 255, 0.08);
}
.city-item:hover::before { opacity: 1; }
.city-item:hover .city-name { color: var(--brand); }
.city-item:hover .count {
  background: var(--brand);
  color: #fff;
  box-shadow: 0 2px 8px rgba(31, 94, 255, 0.3);
}
.city-item:hover .tags .tag { background: #e4ecff; color: var(--brand); }
.city-item .city-name { font-size: 16px; transition: color 0.2s; }
.city-item .count {
  background: var(--brand-soft);
  color: var(--brand);
  border-radius: 999px;
  padding: 2px 9px;
  font-weight: 600;
  transition: background 0.2s, color 0.2s, box-shadow 0.2s;
}
.city-item .tags .tag { background: #f2f5fb; color: #5b6b86; transition: background 0.2s, color 0.2s; }
.city-item .customers {
  border-top: 1px dashed var(--border);
  padding-top: 7px;
}

/* 筛选按钮 */
.chip { padding: 6px 14px; box-shadow: 0 1px 4px rgba(15, 23, 42, 0.05); }
.chip:hover { border-color: #b9ccff; color: var(--brand); }
.chip.active { box-shadow: 0 3px 11px rgba(31, 94, 255, 0.26); }

/* 地图浮层 */
.map-popup {
  border: 1px solid var(--border);
  border-radius: 14px;
}
.map-legend {
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 6px 11px;
}

/* 城市详情 */
.city-hero {
  position: relative;
  overflow: hidden;
  border-radius: 18px;
  padding: 20px 22px;
  background: linear-gradient(135deg, #1f5eff 0%, #4f86ff 58%, #7ba6ff 100%);
  box-shadow: 0 8px 26px rgba(31, 94, 255, 0.22);
}
.city-hero::after {
  content: "";
  position: absolute;
  right: -38px;
  top: -72px;
  width: 190px;
  height: 190px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.13);
}
.city-hero > * { position: relative; z-index: 1; }
.city-hero h1 { font-size: 23px; letter-spacing: 0.01em; }
.city-hero p { font-size: 13.5px; }

.customer-card { padding: 16px 18px; }
.customer-card .head {
  align-items: center;
  padding-bottom: 11px;
  border-bottom: 1px solid var(--border);
}
.customer-card .name {
  display: flex;
  align-items: center;
  gap: 9px;
  font-size: 17px;
}
.customer-card .name::before {
  content: "";
  width: 4px;
  height: 17px;
  border-radius: 2px;
  background: var(--brand);
  flex: none;
}
.customer-card .case {
  background: #f6f9ff;
  border-color: #e3ecff;
  border-left: 3px solid var(--brand);
  border-radius: 10px;
  padding: 11px 13px;
}
.customer-card .case h4 { color: var(--brand); }
.case-images img { border-radius: 10px; transition: transform 0.15s, box-shadow 0.15s; }
.case-images img:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 18px rgba(15, 23, 42, 0.14);
}

.doc-item {
  border-radius: 12px;
  padding: 12px 14px;
  box-shadow: 0 1px 6px rgba(15, 23, 42, 0.035);
  transition: border-color 0.15s, box-shadow 0.15s;
}
.doc-item:hover { border-color: #cdd9ff; box-shadow: 0 5px 16px rgba(31, 94, 255, 0.1); }
.doc-item .icon { border-radius: 10px; }

.locked-card {
  border-radius: 16px;
  border-color: #dce3f2;
  background: linear-gradient(180deg, #ffffff, #fbfcff);
  padding: 28px 18px;
}
.locked-card .lock-icon { box-shadow: 0 0 0 7px rgba(229, 57, 53, 0.08); }

.wecom-card {
  border-radius: 14px;
  background: linear-gradient(135deg, #f2fbf6, #f9fdfa);
}
.wecom-card img {
  border-radius: 10px;
  box-shadow: 0 2px 10px rgba(18, 183, 106, 0.12);
}

/* 表单 / 登录卡片 */
.form-card {
  border-radius: 18px;
  padding: 22px;
  box-shadow: 0 8px 30px rgba(15, 23, 42, 0.07);
}
.form-card h1 {
  font-size: 21px;
  padding-left: 11px;
  position: relative;
}
.form-card h1::before {
  content: "";
  position: absolute;
  left: 0;
  top: 4px;
  bottom: 4px;
  width: 3px;
  border-radius: 2px;
  background: var(--brand);
}
.hint-box { border-radius: 10px; background: #f6f8fc; }

/* ---------- 响应式 ---------- */
@media (min-width: 1024px) {
  .layout { grid-template-columns: 1fr 350px; align-items: start; }
  #map { height: calc(100vh - 230px); min-height: 460px; }
  .city-list { max-height: calc(100vh - 280px); }
  .page { padding: 18px 20px 48px; }
  .hero h1 { font-size: 22px; }
}
@media (max-width: 520px) {
  .grid-2 { grid-template-columns: 1fr; }
  .search-box { flex: 1 1 100%; }
  .doc-item .ops .btn.sm { padding: 5px 8px; }
}
