/* ============================================================
   线索稽查 H5 · Apple 设计语言（Human Interface Guidelines）
   ============================================================ */
:root {
  /* 系统颜色 */
  --blue: #007aff;
  --green: #34c759;
  --red: #ff3b30;
  --orange: #ff9500;
  --yellow: #ffcc00;
  --purple: #af52de;
  --teal: #30b0c7;
  --pink: #ff2d55;
  --indigo: #5856d6;

  /* 标签与背景 */
  --bg: #f2f2f7;
  --bg-elevated: #ffffff;
  --label: #000000;
  --label-2: rgba(60, 60, 67, 0.6);
  --label-3: rgba(60, 60, 67, 0.3);
  --label-4: rgba(60, 60, 67, 0.18);
  --sep: rgba(60, 60, 67, 0.12);
  --fill: rgba(120, 120, 128, 0.12);
  --fill-2: rgba(120, 120, 128, 0.16);

  /* 形状与动效 */
  --r-card: 16px;
  --r-btn: 12px;
  --r-field: 10px;
  --ease: cubic-bezier(0.32, 0.72, 0, 1);
  --dur: 0.35s;

  --tabbar-h: 52px;
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

html,
body {
  height: 100%;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "SF Pro Display", "PingFang SC", "Helvetica Neue", "Microsoft YaHei", sans-serif;
  background: var(--bg);
  color: var(--label);
  font-size: 17px;
  line-height: 1.4;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

a {
  text-decoration: none;
  color: inherit;
}

#app {
  max-width: 560px;
  margin: 0 auto;
  min-height: 100%;
  display: flex;
  flex-direction: column;
  background: var(--bg);
}

/* ============ 顶部导航（毛玻璃） ============ */
.topbar {
  position: sticky;
  top: 0;
  z-index: 30;
  background: rgba(242, 242, 247, 0.82);
  -webkit-backdrop-filter: saturate(180%) blur(20px);
  backdrop-filter: saturate(180%) blur(20px);
  border-bottom: 0.5px solid var(--sep);
  padding: calc(env(safe-area-inset-top) + 8px) 16px 8px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 44px;
}
.topbar-title {
  display: flex;
  align-items: center;
  gap: 10px;
}
.logo {
  width: 30px;
  height: 30px;
  border-radius: 8px;
  background: linear-gradient(180deg, #34c759, #248a3d);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 15px;
  color: #fff;
  box-shadow: 0 2px 6px rgba(52, 199, 89, 0.35);
}
.topbar .t1 {
  font-size: 17px;
  font-weight: 600;
  letter-spacing: -0.2px;
}
.topbar .t2 {
  font-size: 11px;
  color: var(--label-2);
  margin-top: 1px;
}
.topbar-user {
  font-size: 13px;
  color: var(--blue);
  background: var(--fill);
  padding: 5px 12px;
  border-radius: 999px;
  max-width: 128px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ============ 页面容器 ============ */
.page {
  flex: 1;
  padding: 0 16px calc(var(--tabbar-h) + env(safe-area-inset-bottom) + 24px);
}

.large-title {
  font-size: 32px;
  font-weight: 800;
  letter-spacing: -0.6px;
  padding: 12px 0 14px;
}

.loading {
  text-align: center;
  color: var(--label-3);
  padding: 48px 0;
  font-size: 15px;
}

.empty {
  text-align: center;
  color: var(--label-3);
  padding: 44px 0;
  font-size: 15px;
}

/* ============ 分组卡片（iOS  inset grouped） ============ */
.group {
  background: var(--bg-elevated);
  border-radius: var(--r-card);
  margin-bottom: 22px;
  overflow: hidden;
}
.group-head {
  font-size: 13px;
  font-weight: 400;
  color: var(--label-2);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  padding: 0 16px 8px;
}
.group-foot {
  font-size: 13px;
  color: var(--label-2);
  padding: 8px 16px 0;
  line-height: 1.45;
}

.row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  min-height: 46px;
  position: relative;
  background: var(--bg-elevated);
}
.row + .row::before {
  content: "";
  position: absolute;
  top: 0;
  left: 16px;
  right: 0;
  height: 0.5px;
  background: var(--sep);
}
.row.tappable {
  cursor: pointer;
  transition: background 0.15s;
}
.row.tappable:active {
  background: var(--fill);
}
.row-label {
  font-size: 16px;
  flex-shrink: 0;
}
.row-value {
  flex: 1;
  text-align: right;
  font-size: 15px;
  color: var(--label-2);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.row-value.blue {
  color: var(--blue);
}
.row-sub {
  font-size: 12px;
  color: var(--label-3);
  margin-top: 2px;
}
.chevron::after {
  content: "›";
  font-size: 20px;
  color: var(--label-4);
  font-weight: 300;
  margin-left: 4px;
}

/* 统计网格（大数字） */
.stat-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
  margin-bottom: 22px;
}
.stat {
  background: var(--bg-elevated);
  border-radius: var(--r-card);
  padding: 12px 6px 10px;
  text-align: center;
}
.stat .num {
  font-size: 24px;
  font-weight: 700;
  letter-spacing: -0.5px;
  font-variant-numeric: tabular-nums;
}
.stat .label {
  font-size: 11px;
  color: var(--label-2);
  margin-top: 3px;
}
.stat.blue .num { color: var(--blue); }
.stat.red .num { color: var(--red); }
.stat.orange .num { color: var(--orange); }
.stat.purple .num { color: var(--purple); }

/* ============ 按钮 ============ */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  border: none;
  border-radius: var(--r-btn);
  padding: 9px 16px;
  font-size: 15px;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  background: var(--blue);
  color: #fff;
  transition: opacity 0.15s, transform 0.15s;
  letter-spacing: -0.1px;
}
.btn:active {
  opacity: 0.75;
  transform: scale(0.98);
}
.btn.tinted {
  background: rgba(0, 122, 255, 0.12);
  color: var(--blue);
}
.btn.plain {
  background: var(--fill);
  color: var(--label);
}
.btn.danger {
  background: rgba(255, 59, 48, 0.12);
  color: var(--red);
}
.btn.ok {
  background: rgba(52, 199, 89, 0.12);
  color: #248a3d;
}
.btn.warn {
  background: rgba(255, 149, 0, 0.12);
  color: #c93400;
}
.btn.sm {
  padding: 6px 12px;
  font-size: 13px;
  border-radius: 9px;
}
.btn.block {
  width: 100%;
  padding: 13px;
  font-size: 17px;
  border-radius: 14px;
}
.btn:disabled {
  opacity: 0.45;
  pointer-events: none;
}

/* ============ 徽标 ============ */
.tag {
  display: inline-flex;
  align-items: center;
  padding: 2px 9px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 500;
  line-height: 18px;
  white-space: nowrap;
}
.tag.gray { background: var(--fill); color: var(--label-2); }
.tag.blue { background: rgba(0, 122, 255, 0.12); color: var(--blue); }
.tag.red { background: rgba(255, 59, 48, 0.12); color: var(--red); }
.tag.orange { background: rgba(255, 149, 0, 0.14); color: #c93400; }
.tag.green { background: rgba(52, 199, 89, 0.14); color: #248a3d; }
.tag.purple { background: rgba(175, 82, 222, 0.12); color: var(--purple); }
.tag.gold {
  background: linear-gradient(90deg, rgba(255, 204, 0, 0.22), rgba(255, 149, 0, 0.18));
  color: #b25000;
  font-weight: 600;
}

/* ============ 分段控件 ============ */
.segmented {
  display: flex;
  background: var(--fill);
  border-radius: 10px;
  padding: 2px;
  margin-bottom: 14px;
  position: relative;
}
.segmented .seg {
  flex: 1;
  text-align: center;
  font-size: 13px;
  font-weight: 500;
  color: var(--label-2);
  padding: 7px 4px;
  border-radius: 8px;
  cursor: pointer;
  transition: all var(--dur) var(--ease);
  white-space: nowrap;
}
.segmented .seg.on {
  background: #fff;
  color: var(--label);
  font-weight: 600;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.1), 0 0 0 0.5px rgba(0, 0, 0, 0.02);
}

/* ============ 开关（iOS Switch） ============ */
.switch {
  position: relative;
  width: 50px;
  height: 30px;
  flex-shrink: 0;
  cursor: pointer;
}
.switch input {
  display: none;
}
.switch .track {
  position: absolute;
  inset: 0;
  border-radius: 999px;
  background: var(--fill-2);
  transition: background var(--dur) var(--ease);
}
.switch .knob {
  position: absolute;
  top: 2px;
  left: 2px;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 2px 5px rgba(0, 0, 0, 0.2), 0 0 0 0.5px rgba(0, 0, 0, 0.04);
  transition: transform var(--dur) var(--ease);
}
.switch input:checked ~ .track {
  background: var(--green);
}
.switch input:checked ~ .knob {
  transform: translateX(20px);
}

/* ============ 搜索框 ============ */
.search {
  width: 100%;
  border: none;
  background: var(--fill);
  border-radius: 10px;
  padding: 9px 12px 9px 32px;
  font-size: 16px;
  margin-bottom: 14px;
  outline: none;
  font-family: inherit;
  color: var(--label);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='15' height='15' viewBox='0 0 24 24' fill='none' stroke='%238e8e93' stroke-width='2.4' stroke-linecap='round'%3E%3Ccircle cx='11' cy='11' r='7'/%3E%3Cpath d='M20 20l-3.8-3.8'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: 10px center;
}
.search::placeholder {
  color: var(--label-3);
}

/* ============ 线索卡片 ============ */
.lead-card {
  cursor: pointer;
  transition: transform 0.15s var(--ease);
}
.lead-card:active {
  transform: scale(0.985);
}
.lead-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 4px;
}
.lead-name {
  font-size: 17px;
  font-weight: 600;
  letter-spacing: -0.2px;
}
.lead-phone {
  color: var(--label-3);
  font-size: 13px;
  margin-left: 8px;
}
.lead-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 3px 12px;
  color: var(--label-2);
  font-size: 13px;
  margin-top: 5px;
}
.lead-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 12px;
  color: var(--label-3);
  margin-top: 10px;
  padding-top: 10px;
  border-top: 0.5px solid var(--sep);
}
.vio-mini {
  color: var(--red);
  font-weight: 500;
}

/* ============ 违规卡片 ============ */
.vio-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 4px;
}
.vio-rule {
  font-size: 16px;
  font-weight: 600;
  letter-spacing: -0.2px;
}
.vio-detail {
  font-size: 13px;
  color: var(--label-2);
  margin: 6px 0;
  line-height: 1.5;
  word-break: break-all;
}
.vio-lead {
  font-size: 12px;
  color: var(--label-3);
  margin-bottom: 10px;
}
.vio-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  align-items: center;
}
.remind-progress {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: var(--label-2);
}
.dots {
  display: inline-flex;
  gap: 4px;
}
.dots i {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--fill-2);
}
.dots i.on { background: var(--orange); }
.dots i.pen { background: var(--red); }

/* ============ 时间线 ============ */
.timeline {
  border-left: 2px solid var(--sep);
  margin: 10px 0 4px 4px;
  padding-left: 16px;
}
.tl-item {
  position: relative;
  padding-bottom: 16px;
  font-size: 13px;
}
.tl-item::before {
  content: "";
  position: absolute;
  left: -21px;
  top: 5px;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--blue);
}
.tl-item .tl-time {
  color: var(--label-3);
  font-size: 11px;
}
.tl-item .tl-content {
  color: var(--label);
  margin: 3px 0;
  line-height: 1.5;
  word-break: break-all;
}
.tl-item .tl-fields {
  color: var(--label-2);
  font-size: 12px;
}

/* ============ 底部弹层（Sheet） ============ */
.modal-mask {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.36);
  z-index: 60;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  animation: fadein 0.25s var(--ease);
}
.modal {
  background: var(--bg);
  border-radius: 12px 12px 0 0;
  width: 100%;
  max-width: 560px;
  max-height: 88vh;
  overflow-y: auto;
  padding: 8px 16px calc(env(safe-area-inset-bottom) + 20px);
  animation: slideup var(--dur) var(--ease);
}
@keyframes slideup {
  from { transform: translateY(100%); }
  to { transform: translateY(0); }
}
@keyframes fadein {
  from { opacity: 0; }
  to { opacity: 1; }
}
.grabber {
  width: 36px;
  height: 5px;
  border-radius: 999px;
  background: var(--label-4);
  margin: 4px auto 12px;
}
.modal-title {
  font-size: 22px;
  font-weight: 800;
  letter-spacing: -0.4px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 14px;
}
.modal-close {
  color: var(--label-3);
  font-size: 22px;
  padding: 0 4px;
  font-weight: 400;
}

/* ============ 表单 ============ */
.form-item {
  margin-bottom: 14px;
}
.form-item label {
  display: block;
  font-size: 13px;
  font-weight: 500;
  color: var(--label-2);
  margin: 0 0 6px 4px;
}
.form-item input,
.form-item select,
.form-item textarea {
  width: 100%;
  border: none;
  border-radius: var(--r-field);
  padding: 11px 12px;
  font-size: 16px;
  font-family: inherit;
  outline: none;
  background: var(--fill);
  color: var(--label);
  transition: box-shadow 0.15s;
}
.form-item input:focus,
.form-item select:focus,
.form-item textarea:focus {
  box-shadow: 0 0 0 3px rgba(0, 122, 255, 0.18);
}
.form-item textarea {
  resize: none;
  line-height: 1.5;
}
.form-row {
  display: flex;
  gap: 10px;
}
.form-row .form-item {
  flex: 1;
  min-width: 0;
}

/* ============ 规则页 ============ */
.rule-sec h3 {
  font-size: 17px;
  font-weight: 700;
  margin-bottom: 4px;
  letter-spacing: -0.2px;
}
.rule-sec ul {
  padding-left: 20px;
  font-size: 14px;
  color: var(--label);
}
.rule-sec li {
  margin-bottom: 7px;
  line-height: 1.55;
  word-break: break-all;
}
.auto-box {
  background: rgba(0, 122, 255, 0.07);
  border-radius: 10px;
  padding: 10px 12px;
  margin-top: 10px;
  font-size: 12.5px;
  color: var(--label-2);
  line-height: 1.6;
}
.auto-box b {
  color: var(--blue);
}

/* ============ 规则分布 ============ */
.bar-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 10px;
  font-size: 13px;
}
.bar-row .name {
  width: 112px;
  flex-shrink: 0;
  color: var(--label-2);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.bar-row .bar {
  flex: 1;
  height: 7px;
  background: var(--fill);
  border-radius: 4px;
  overflow: hidden;
}
.bar-row .bar i {
  display: block;
  height: 100%;
  background: linear-gradient(90deg, #ff9500, #ff3b30);
  border-radius: 4px;
  transition: width var(--dur) var(--ease);
}
.bar-row .cnt {
  width: 24px;
  text-align: right;
  color: var(--label-2);
  font-variant-numeric: tabular-nums;
}

/* ============ Tab 栏 ============ */
.tabbar {
  position: fixed;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 100%;
  max-width: 560px;
  background: rgba(255, 255, 255, 0.86);
  -webkit-backdrop-filter: saturate(180%) blur(20px);
  backdrop-filter: saturate(180%) blur(20px);
  border-top: 0.5px solid var(--sep);
  display: flex;
  padding: 6px 0 calc(env(safe-area-inset-bottom) + 4px);
  z-index: 40;
}
.tabbar a {
  flex: 1;
  text-align: center;
  font-size: 10px;
  color: var(--label-2);
  position: relative;
  padding: 2px 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  transition: color 0.15s;
}
.tabbar a svg {
  width: 24px;
  height: 24px;
}
.tabbar a.on {
  color: var(--blue);
}
.tabbar a.on svg {
  stroke: var(--blue);
}
.badge {
  position: absolute;
  top: -2px;
  right: calc(50% - 20px);
  min-width: 17px;
  height: 17px;
  background: var(--red);
  color: #fff;
  border-radius: 999px;
  font-size: 10px;
  font-weight: 600;
  line-height: 17px;
  font-style: normal;
  padding: 0 5px;
}

/* ============ Toast ============ */
.toast {
  position: fixed;
  left: 50%;
  bottom: 120px;
  transform: translateX(-50%);
  background: rgba(0, 0, 0, 0.78);
  -webkit-backdrop-filter: blur(10px);
  backdrop-filter: blur(10px);
  color: #fff;
  font-size: 14px;
  font-weight: 500;
  padding: 10px 18px;
  border-radius: 14px;
  z-index: 99;
  max-width: 82%;
  text-align: center;
  animation: toastin 0.3s var(--ease);
}
@keyframes toastin {
  from { opacity: 0; transform: translateX(-50%) translateY(10px) scale(0.95); }
  to { opacity: 1; transform: translateX(-50%) translateY(0) scale(1); }
}

/* ============ 滑块（iOS Slider） ============ */
.slider {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 28px;
  background: transparent;
  outline: none;
  cursor: pointer;
}
.slider::-webkit-slider-runnable-track {
  height: 6px;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--blue) var(--fill-pct, 0%), var(--fill) var(--fill-pct, 0%));
}
.slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.18), 0 0 0 0.5px rgba(0, 0, 0, 0.04);
  margin-top: -10px;
  transition: transform 0.15s var(--ease);
}
.slider:active::-webkit-slider-thumb {
  transform: scale(1.12);
}
.slider::-moz-range-track {
  height: 6px;
  border-radius: 999px;
  background: var(--fill);
}
.slider::-moz-range-progress {
  height: 6px;
  border-radius: 999px;
  background: var(--blue);
}
.slider::-moz-range-thumb {
  width: 26px;
  height: 26px;
  border: none;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.18);
}

/* ============ 工具类 ============ */
.mt6 { margin-top: 6px; }
.mt10 { margin-top: 10px; }
.mt14 { margin-top: 14px; }
.mt20 { margin-top: 20px; }
.mb10 { margin-bottom: 10px; }
.mb14 { margin-bottom: 14px; }
.flex { display: flex; align-items: center; gap: 8px; }
.flex-between { display: flex; align-items: center; justify-content: space-between; }
.grow { flex: 1; min-width: 0; }
.text-2 { color: var(--label-2); }
.text-3 { color: var(--label-3); }
.small { font-size: 13px; }
.tiny { font-size: 12px; }
.bold { font-weight: 600; }
.center { text-align: center; }
.nowrap { white-space: nowrap; }
.mono {
  font-family: ui-monospace, SFMono-Regular, "SF Mono", Menlo, monospace;
  font-size: 12px;
}

/* 键值对 */
.kv {
  display: flex;
  font-size: 15px;
  padding: 9px 0;
  border-bottom: 0.5px solid var(--sep);
}
.kv:last-child {
  border-bottom: none;
}
.kv .k {
  width: 92px;
  flex-shrink: 0;
  color: var(--label-2);
  font-size: 13px;
  padding-top: 1px;
}
.kv .v {
  flex: 1;
  word-break: break-all;
}

/* 状态点 */
.scan-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--green);
  flex-shrink: 0;
  animation: pulse 2.4s infinite;
}
@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.3; }
}
