/* ============================================================
   客户信息记录 H5 —— 样式
   ============================================================ */

:root {
  --bg: #f4f5f7;
  --card: #ffffff;
  --text: #111827;
  --text-2: #4b5563;
  --muted: #8b93a1;
  --line: #e8eaee;
  --brand: #2563eb;
  --brand-dark: #1d4ed8;
  --brand-weak: #eef3ff;
  --ok: #16a34a;
  --ok-weak: #eaf7ef;
  --warn: #d97706;
  --warn-weak: #fef6e7;
  --danger: #dc2626;
  --danger-weak: #fdeeee;
  --shadow: 0 1px 2px rgba(16, 24, 40, 0.04), 0 6px 20px rgba(16, 24, 40, 0.06);
  --radius: 14px;
  --tabbar-h: 56px;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

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

body {
  min-height: 100vh;
  min-height: 100dvh;
}

button, input, textarea, select {
  font-family: inherit;
  font-size: inherit;
  color: inherit;
}

/* ---------- 布局骨架 ---------- */
.app {
  max-width: 560px;
  margin: 0 auto;
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  background: var(--bg);
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 16px;
  background: rgba(255, 255, 255, 0.88);
  backdrop-filter: saturate(180%) blur(12px);
  -webkit-backdrop-filter: saturate(180%) blur(12px);
  border-bottom: 1px solid var(--line);
}

.topbar h1 {
  margin: 0;
  font-size: 17px;
  font-weight: 650;
  letter-spacing: 0.2px;
  flex: 1;
  min-width: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.topbar .logo {
  width: 28px; height: 28px;
  border-radius: 9px;
  background: linear-gradient(135deg, #3b82f6, #2563eb);
  display: grid; place-items: center;
  color: #fff; font-size: 15px; font-weight: 700;
  flex: none;
  box-shadow: 0 2px 8px rgba(37, 99, 235, 0.3);
}

.icon-btn {
  border: none;
  background: transparent;
  width: 36px; height: 36px;
  border-radius: 10px;
  display: grid; place-items: center;
  cursor: pointer;
  color: var(--text-2);
  flex: none;
}
.icon-btn:active { background: #eceef2; }
.icon-btn svg { width: 20px; height: 20px; }

.main {
  flex: 1;
  padding: 14px 14px calc(var(--tabbar-h) + 24px);
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.view { display: none; flex-direction: column; gap: 14px; }
.view.active { display: flex; }

/* ---------- 卡片 ---------- */
.card {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 14px;
}

.card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 10px;
}

.card-title {
  font-size: 14px;
  font-weight: 650;
  color: var(--text);
  display: flex;
  align-items: center;
  gap: 6px;
}

.card-title .dot {
  width: 6px; height: 6px; border-radius: 50%;
  background: var(--brand);
}

.card-sub { font-size: 12.5px; color: var(--muted); }

/* ---------- 粘贴区 ---------- */
.paste-wrap { position: relative; }

#pasteBox {
  width: 100%;
  min-height: 128px;
  max-height: 280px;
  resize: vertical;
  border: 1.5px dashed #cfd6e4;
  border-radius: 12px;
  background: #fbfcfe;
  padding: 12px 13px;
  padding-right: 96px;
  font-size: 14.5px;
  line-height: 1.7;
  outline: none;
  transition: border-color .18s, background .18s;
}
#pasteBox:focus {
  border-color: var(--brand);
  background: #fff;
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}
#pasteBox::placeholder { color: #a9b0bd; }

.paste-actions {
  position: absolute;
  top: 10px; right: 10px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.mini-btn {
  border: 1px solid var(--line);
  background: #fff;
  color: var(--text-2);
  border-radius: 8px;
  padding: 5px 10px;
  font-size: 12.5px;
  cursor: pointer;
  white-space: nowrap;
  transition: all .15s;
}
.mini-btn:hover { border-color: #c7d2e5; color: var(--text); }
.mini-btn:active { transform: scale(.97); }

/* ---------- 识别结果条 ---------- */
.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 10px;
  min-height: 26px;
}
.chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 12px;
  padding: 3px 9px;
  border-radius: 20px;
  background: var(--ok-weak);
  color: #157f3d;
  border: 1px solid #c9ead6;
  animation: pop .18s ease-out;
}
.chip.miss {
  background: #f3f4f6;
  color: var(--muted);
  border-color: var(--line);
}
.chip b { font-weight: 650; }
@keyframes pop {
  from { transform: scale(.9); opacity: 0; }
  to { transform: scale(1); opacity: 1; }
}

/* ---------- 表单 ---------- */
.form { display: flex; flex-direction: column; gap: 11px; }

.field { display: flex; flex-direction: column; gap: 5px; }

.field label {
  font-size: 12.5px;
  color: var(--muted);
  font-weight: 550;
  display: flex;
  align-items: center;
  gap: 5px;
}
.field label .req { color: var(--brand); font-size: 11px; }

.field input,
.field textarea {
  border: 1px solid var(--line);
  background: #fbfcfe;
  border-radius: 10px;
  padding: 10px 12px;
  outline: none;
  transition: border-color .16s, box-shadow .16s, background .16s;
  width: 100%;
}
.field textarea { min-height: 62px; resize: vertical; line-height: 1.6; }

.field input:focus,
.field textarea:focus {
  border-color: var(--brand);
  background: #fff;
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.09);
}

.field.filled input { background: #fff; border-color: #d7dced; }

/* ---------- 按钮 ---------- */
.btn {
  border: none;
  border-radius: 11px;
  padding: 11px 16px;
  font-size: 14.5px;
  font-weight: 600;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  transition: transform .12s, background .16s, box-shadow .16s;
  white-space: nowrap;
}
.btn:active { transform: scale(.985); }
.btn-primary { background: var(--brand); color: #fff; box-shadow: 0 2px 10px rgba(37,99,235,.22); }
.btn-primary:hover { background: var(--brand-dark); }
.btn-ghost { background: #fff; color: var(--text-2); border: 1px solid var(--line); }
.btn-ghost:hover { background: #f7f8fa; }
.btn-danger { background: var(--danger-weak); color: var(--danger); border: 1px solid #f6d3d3; }
.btn-danger:hover { background: #fbe2e2; }
.btn-block { width: 100%; }
.btn[disabled] { opacity: .55; pointer-events: none; }
.btn-row { display: flex; gap: 9px; }
.btn-row .btn { flex: 1; }

/* ---------- 保存状态 ---------- */
.savebar {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12.5px;
  color: var(--muted);
  padding: 8px 12px;
  border-radius: 10px;
  background: #f7f8fa;
  border: 1px solid var(--line);
  transition: all .2s;
}
.savebar .spinner {
  width: 12px; height: 12px;
  border: 2px solid #cfd6e4;
  border-top-color: var(--brand);
  border-radius: 50%;
  animation: spin .7s linear infinite;
  flex: none;
}
@keyframes spin { to { transform: rotate(360deg); } }
.savebar.ok { background: var(--ok-weak); border-color: #c9ead6; color: #157f3d; }
.savebar.err { background: var(--danger-weak); border-color: #f6d3d3; color: var(--danger); }
.savebar .ico { font-size: 13px; }

/* ---------- 批量识别面板 ---------- */
.batch-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-height: 320px;
  overflow: auto;
  margin: 10px 0;
}
.batch-item {
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 9px 11px;
  background: #fbfcfe;
  font-size: 13px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.batch-item .r1 { font-weight: 650; display: flex; align-items: center; gap: 8px; }
.batch-item .r1 .ph { color: var(--brand); font-weight: 600; font-variant-numeric: tabular-nums; }
.batch-item .r2 { color: var(--muted); font-size: 12.5px; }
.batch-item .r3 { color: #9aa2b1; font-size: 12px; }
.batch-item .idx {
  width: 18px; height: 18px; border-radius: 5px; background: #e8edf8; color: #4b6cb7;
  font-size: 11px; display: grid; place-items: center; flex: none; font-weight: 600;
}

/* ---------- 统计条 ---------- */
.stats {
  display: flex;
  gap: 8px;
}
.stat {
  flex: 1;
  background: var(--card);
  border-radius: 12px;
  box-shadow: var(--shadow);
  padding: 10px 12px;
  text-align: center;
}
.stat .n { font-size: 19px; font-weight: 700; letter-spacing: -.3px; }
.stat .l { font-size: 11.5px; color: var(--muted); margin-top: 1px; }
.stat.brand .n { color: var(--brand); }

/* ---------- 搜索 ---------- */
.search-wrap { position: relative; }
.search-wrap svg {
  position: absolute; left: 11px; top: 50%; transform: translateY(-50%);
  width: 16px; height: 16px; color: var(--muted);
}
#searchInput {
  width: 100%;
  border: 1px solid var(--line);
  background: var(--card);
  border-radius: 11px;
  padding: 10px 34px 10px 33px;
  outline: none;
  box-shadow: var(--shadow);
  transition: border-color .16s, box-shadow .16s;
}
#searchInput:focus { border-color: var(--brand); box-shadow: 0 0 0 3px rgba(37,99,235,.09); }
.search-clear {
  position: absolute; right: 8px; top: 50%; transform: translateY(-50%);
  border: none; background: #eceef2; color: var(--muted);
  width: 20px; height: 20px; border-radius: 50%; cursor: pointer;
  display: none; place-items: center; font-size: 13px; line-height: 1;
}
.search-clear.show { display: grid; }

/* ---------- 客户列表 ---------- */
.list { display: flex; flex-direction: column; gap: 9px; }

.customer {
  background: var(--card);
  border-radius: 13px;
  box-shadow: var(--shadow);
  padding: 12px 13px;
  cursor: pointer;
  transition: transform .12s, box-shadow .16s;
  position: relative;
  overflow: hidden;
}
.customer:active { transform: scale(.99); }

.customer .row1 {
  display: flex;
  align-items: baseline;
  gap: 9px;
  margin-bottom: 5px;
}
.customer .cname {
  font-size: 15.5px;
  font-weight: 660;
  letter-spacing: .1px;
}
.customer .cname.empty { color: var(--muted); font-weight: 500; font-size: 14px; }
.customer .cphone {
  font-size: 13px;
  color: var(--brand);
  font-variant-numeric: tabular-nums;
  margin-left: auto;
  flex: none;
  display: flex;
  align-items: center;
  gap: 5px;
}
.customer .cphone a { color: inherit; text-decoration: none; }
.customer .line {
  font-size: 13px;
  color: var(--text-2);
  display: flex;
  gap: 6px;
  line-height: 1.5;
}
.customer .line + .line { margin-top: 2px; }
.customer .line .k { color: #aeb5c2; flex: none; width: 30px; }
.customer .line .v {
  overflow: hidden;
  text-overflow: ellipsis;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}
.customer .foot {
  margin-top: 7px;
  padding-top: 7px;
  border-top: 1px dashed var(--line);
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 11.5px;
  color: #a7aebb;
}
.customer .del {
  margin-left: auto;
  border: none;
  background: transparent;
  color: #c3c9d4;
  cursor: pointer;
  padding: 2px 4px;
  border-radius: 6px;
  font-size: 12.5px;
  display: flex;
  align-items: center;
  gap: 3px;
}
.customer .del:hover { color: var(--danger); background: var(--danger-weak); }

/* ---------- 空状态 ---------- */
.empty {
  text-align: center;
  padding: 44px 20px;
  color: var(--muted);
}
.empty .big { font-size: 34px; margin-bottom: 8px; opacity: .55; }
.empty .t { font-size: 14px; color: var(--text-2); font-weight: 550; }
.empty .d { font-size: 12.5px; margin-top: 4px; }

/* ---------- 数据页 ---------- */
.data-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 2px;
  border-bottom: 1px solid var(--line);
  cursor: pointer;
}
.data-item:last-child { border-bottom: none; }
.data-item .di {
  width: 38px; height: 38px; border-radius: 11px;
  display: grid; place-items: center;
  background: var(--brand-weak); color: var(--brand);
  flex: none; font-size: 17px;
}
.data-item .di.green { background: var(--ok-weak); color: #157f3d; }
.data-item .di.orange { background: var(--warn-weak); color: var(--warn); }
.data-item .di.gray { background: #f0f1f4; color: var(--text-2); }
.data-item .dt { flex: 1; min-width: 0; }
.data-item .dt .t { font-size: 14.5px; font-weight: 570; }
.data-item .dt .d { font-size: 12px; color: var(--muted); margin-top: 1px; }
.data-item .arrow { color: #c8cdd6; flex: none; }

/* ---------- 底部导航 ---------- */
.tabbar {
  position: fixed;
  left: 0; right: 0; bottom: 0;
  z-index: 30;
  height: calc(var(--tabbar-h) + env(safe-area-inset-bottom, 0px));
  padding-bottom: env(safe-area-inset-bottom, 0px);
  display: flex;
  background: rgba(255, 255, 255, 0.94);
  backdrop-filter: saturate(180%) blur(12px);
  -webkit-backdrop-filter: saturate(180%) blur(12px);
  border-top: 1px solid var(--line);
}
.tabbar-inner {
  max-width: 560px;
  margin: 0 auto;
  width: 100%;
  display: flex;
}
.tab {
  flex: 1;
  border: none;
  background: transparent;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  color: var(--muted);
  font-size: 11px;
  cursor: pointer;
  padding: 6px 0;
  transition: color .16s;
}
.tab svg { width: 21px; height: 21px; }
.tab.active { color: var(--brand); }
.tab.active svg { transform: translateY(-1px); }
.tab svg { transition: transform .16s; }

/* ---------- 弹层 ---------- */
.mask {
  position: fixed;
  inset: 0;
  background: rgba(17, 24, 39, 0.42);
  z-index: 50;
  display: none;
  align-items: flex-end;
  justify-content: center;
  backdrop-filter: blur(2px);
}
.mask.show { display: flex; animation: fade .18s; }
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }

.sheet {
  background: #fff;
  width: 100%;
  max-width: 560px;
  border-radius: 18px 18px 0 0;
  padding: 8px 16px calc(20px + env(safe-area-inset-bottom, 0px));
  max-height: 92vh;
  overflow: auto;
  animation: slideUp .24s cubic-bezier(.22, .8, .3, 1);
}
.sheet.center {
  border-radius: 16px;
  margin: auto 16px;
  align-self: center;
  animation: zoomIn .2s cubic-bezier(.22, .8, .3, 1);
}
@keyframes slideUp { from { transform: translateY(24px); opacity: .6; } to { transform: none; opacity: 1; } }
@keyframes zoomIn { from { transform: scale(.94); opacity: 0; } to { transform: none; opacity: 1; } }

.sheet .grab {
  width: 36px; height: 4px; border-radius: 2px;
  background: #e2e5ea;
  margin: 4px auto 12px;
}
.sheet-title {
  font-size: 16px;
  font-weight: 660;
  margin-bottom: 12px;
  display: flex;
  align-items: center;
  gap: 8px;
}
.sheet-title .close {
  margin-left: auto;
  border: none; background: #f0f1f4; color: var(--text-2);
  width: 26px; height: 26px; border-radius: 50%; cursor: pointer;
  font-size: 15px; line-height: 1;
}

.sheet-actions { display: flex; gap: 9px; margin-top: 14px; }
.sheet-actions .btn { flex: 1; }

/* ---------- Toast ---------- */
.toast-wrap {
  position: fixed;
  left: 0; right: 0;
  top: calc(env(safe-area-inset-top, 0px) + 14px);
  z-index: 100;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  pointer-events: none;
}
.toast {
  background: rgba(24, 30, 42, 0.93);
  color: #fff;
  font-size: 13.5px;
  padding: 9px 16px;
  border-radius: 10px;
  max-width: 80vw;
  box-shadow: 0 6px 24px rgba(0, 0, 0, .22);
  animation: toastIn .22s cubic-bezier(.22,.8,.3,1);
}
.toast.ok { background: rgba(21, 127, 61, .95); }
.toast.err { background: rgba(200, 38, 38, .95); }
@keyframes toastIn { from { transform: translateY(-10px); opacity: 0; } to { transform: none; opacity: 1; } }

/* ---------- 提示条 ---------- */
.hint {
  font-size: 12.5px;
  color: var(--text-2);
  background: var(--brand-weak);
  border: 1px solid #dbe5fb;
  border-radius: 10px;
  padding: 9px 11px;
  line-height: 1.6;
}
.hint.warn { background: var(--warn-weak); border-color: #f3e2c0; color: #92610c; }
.hint b { font-weight: 650; }

/* ---------- 加载更多 ---------- */
.loadmore {
  text-align: center;
  padding: 12px;
  font-size: 13px;
  color: var(--muted);
  cursor: pointer;
}
.loadmore:active { color: var(--brand); }

/* ---------- 登录页 ---------- */
.login-page {
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: linear-gradient(170deg, #eef3ff 0%, #f4f5f7 46%, #f4f5f7 100%);
}
.login-card {
  width: 100%;
  max-width: 380px;
  background: #fff;
  border-radius: 18px;
  box-shadow: 0 10px 40px rgba(16, 24, 40, .1), 0 2px 6px rgba(16,24,40,.04);
  padding: 30px 24px 24px;
}
.login-card .brand {
  width: 52px; height: 52px;
  border-radius: 15px;
  background: linear-gradient(135deg, #3b82f6, #2563eb);
  display: grid; place-items: center;
  color: #fff; font-size: 25px; font-weight: 700;
  margin: 0 auto 14px;
  box-shadow: 0 6px 20px rgba(37, 99, 235, .3);
}
.login-card h1 {
  font-size: 19px;
  text-align: center;
  margin: 0 0 4px;
  font-weight: 680;
  letter-spacing: .2px;
}
.login-card .sub {
  text-align: center;
  font-size: 13px;
  color: var(--muted);
  margin-bottom: 22px;
}
.login-card .form { gap: 12px; }
.login-err {
  font-size: 13px;
  color: var(--danger);
  background: var(--danger-weak);
  border: 1px solid #f6d3d3;
  border-radius: 9px;
  padding: 8px 11px;
  display: none;
}
.login-err.show { display: block; }
.login-foot {
  text-align: center;
  font-size: 11.5px;
  color: #b0b7c3;
  margin-top: 18px;
}

@media (min-width: 561px) {
  .app { box-shadow: 0 0 40px rgba(16,24,40,.05); }
  .tabbar { left: 50%; right: auto; transform: translateX(-50%); max-width: 560px; }
}
