:root {
  --bg: #f5f5f7;
  --card: #ffffff;
  --blue: #0071e3;
  --blue-dark: #005bbd;
  --text: #1d1d1f;
  --text-2: #6e6e73;
  --text-3: #86868b;
  --hairline: #d2d2d7;
  --hairline-soft: #e8e8ed;
  --green: #34a853;
  --orange: #ff9f0a;
  --red: #ff3b30;
  --radius: 18px;
  --shadow: 0 1px 3px rgba(0,0,0,.04), 0 8px 24px rgba(0,0,0,.05);
}
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Helvetica Neue", "Microsoft YaHei", Arial, sans-serif;
  letter-spacing: -0.01em;
  -webkit-font-smoothing: antialiased;
  font-size: 15px;
  line-height: 1.5;
}
.hidden { display: none !important; }

/* ---------- 登录 ---------- */
.login-view {
  min-height: 100vh;
  display: flex; align-items: center; justify-content: center;
  background: var(--bg);
}
.login-card {
  background: var(--card);
  width: 360px; max-width: 90vw;
  border-radius: 28px;
  padding: 48px 36px 40px;
  box-shadow: var(--shadow);
  text-align: center;
}
.login-logo { font-size: 40px; line-height: 1; margin-bottom: 14px; color: var(--text); }
.login-title { font-size: 26px; font-weight: 600; margin: 0 0 4px; letter-spacing: -0.02em; }
.login-sub { color: var(--text-3); font-size: 13px; margin: 0 0 28px; letter-spacing: .08em; text-transform: uppercase; }
.login-form { display: flex; flex-direction: column; gap: 12px; }
.login-hint { color: var(--text-3); font-size: 12px; margin-top: 22px; line-height: 1.6; }

/* ---------- 顶栏 ---------- */
.topbar {
  position: sticky; top: 0; z-index: 20;
  background: rgba(245,245,247,.85);
  backdrop-filter: saturate(180%) blur(20px);
  -webkit-backdrop-filter: saturate(180%) blur(20px);
  border-bottom: 1px solid var(--hairline-soft);
  display: flex; align-items: center; gap: 24px;
  padding: 0 28px; height: 56px;
}
.brand { font-size: 18px; font-weight: 600; letter-spacing: -0.02em; }
.tabs { display: flex; gap: 6px; margin-left: 8px; }
.tab {
  border: none; background: transparent; cursor: pointer;
  font-size: 14px; color: var(--text-2);
  padding: 7px 14px; border-radius: 980px; transition: .2s;
}
.tab:hover { color: var(--text); background: rgba(0,0,0,.04); }
.tab.active { color: #fff; background: var(--blue); }
.userbox { margin-left: auto; display: flex; align-items: center; gap: 14px; }
.user-name { font-size: 13px; color: var(--text-2); }

/* ---------- 内容 ---------- */
.content { max-width: 1080px; margin: 0 auto; padding: 32px 28px 64px; }
.section-head {
  display: flex; align-items: center; gap: 14px; margin-bottom: 22px;
}
.section-title { font-size: 28px; font-weight: 600; letter-spacing: -0.02em; margin: 0; }
.section-head .spacer { flex: 1; }

/* ---------- 统计卡 ---------- */
.stats-row { display: grid; grid-template-columns: repeat(6, 1fr); gap: 16px; margin-bottom: 26px; }
.stat-card {
  background: var(--card); border-radius: var(--radius); padding: 20px 22px; box-shadow: var(--shadow);
}
.stat-label { font-size: 13px; color: var(--text-3); margin-bottom: 8px; }
.stat-value { font-size: 24px; font-weight: 600; letter-spacing: -0.02em; }
.stat-value.small { font-size: 20px; }
.stat-sub { font-size: 12px; color: var(--text-3); margin-top: 5px; }
.stat-card.accent-risk { box-shadow: 0 0 0 1.5px rgba(255,59,48,.35), 0 1px 3px rgba(0,0,0,.04), 0 8px 24px rgba(0,0,0,.05); }
.stat-card.accent-risk .stat-value { color: var(--red); }
.stat-card.accent-closed { box-shadow: 0 0 0 1.5px rgba(134,134,139,.3), 0 1px 3px rgba(0,0,0,.04), 0 8px 24px rgba(0,0,0,.05); }
.stat-card.accent-closed .stat-value { color: var(--text-2); }
.stat-card.accent-complaint { box-shadow: 0 0 0 1.5px rgba(255,59,48,.35), 0 1px 3px rgba(0,0,0,.04), 0 8px 24px rgba(0,0,0,.05); }
.stat-card.accent-complaint .stat-value { color: var(--red); }

/* ---------- 统计卡 = 可点击筛选器 ---------- */
.stat-card.clickable { cursor: pointer; user-select: none; transition: box-shadow .15s; }
.stat-card.clickable:hover { box-shadow: 0 0 0 1.5px rgba(0,113,227,.45), 0 1px 3px rgba(0,0,0,.04), 0 8px 24px rgba(0,0,0,.06); }
.stat-card.clickable.active { box-shadow: 0 0 0 2px var(--blue), 0 8px 24px rgba(0,113,227,.14); }
.stat-card.clickable.active .stat-value { color: var(--blue); }
.stat-card.clickable.active.accent-risk { box-shadow: 0 0 0 2px var(--red), 0 8px 24px rgba(255,59,48,.14); }
.stat-card.clickable.active.accent-risk .stat-value { color: var(--red); }
.stat-card.clickable.active.accent-complaint { box-shadow: 0 0 0 2px var(--red), 0 8px 24px rgba(255,59,48,.14); }
.stat-card.clickable.active.accent-complaint .stat-value { color: var(--red); }

/* 卡内小胶囊（如「正常 N」），点它单独筛选该状态 */
.chip {
  display: inline-block; padding: 1px 8px; border-radius: 980px;
  background: rgba(0,113,227,.1); color: var(--blue); font-weight: 500;
  cursor: pointer; transition: .15s;
}
.chip:hover { background: rgba(0,113,227,.2); }
.chip.on { background: var(--blue); color: #fff; }

/* 当前筛选提示条 */
.filter-bar { display: flex; align-items: center; gap: 12px; margin: -8px 0 18px; flex-wrap: wrap; }
.filter-badge {
  font-size: 13px; color: var(--text-2); background: var(--card);
  border-radius: 980px; padding: 7px 16px; box-shadow: var(--shadow);
}
.filter-badge b { color: var(--blue); font-weight: 600; }
.filter-bar .btn-secondary { padding: 6px 14px; font-size: 13px; }

/* 复选框内联标签（如「标记为投诉」） */
.chk { display: inline-flex; align-items: center; gap: 6px; font-size: 14px; color: var(--text-2); white-space: nowrap; cursor: pointer; user-select: none; }
.chk input { width: 16px; height: 16px; accent-color: var(--blue); margin: 0; }

/* ---------- 财务简报（按客户聚合） ---------- */
.brief-summary { color: var(--text-3); font-size: 13px; margin-bottom: 16px; }
.client-card { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: 18px 22px; margin-bottom: 14px; }
.client-head { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; }
.client-name { font-size: 17px; font-weight: 600; }
.client-count { margin-left: auto; font-size: 12px; color: var(--text-3); }
.coll-list { border-top: 1px solid var(--hairline-soft); }
.coll-row { padding: 12px 0; border-bottom: 1px solid var(--hairline-soft); }
.coll-row:last-child { border-bottom: none; }
.coll-row:hover { background: #fafafc; margin: 0 -12px; padding: 12px; border-radius: 10px; }
.coll-main { display: flex; align-items: center; gap: 10px; margin-bottom: 4px; flex-wrap: wrap; }
.coll-date { font-size: 13px; color: var(--text-3); }
.coll-cause { font-size: 14px; color: var(--text); }
.coll-money { font-size: 13px; color: var(--text-2); font-variant-numeric: tabular-nums; }
.coll-money b { color: var(--text); }
.coll-desc { font-size: 13px; color: var(--text-2); margin-top: 4px; white-space: pre-wrap; }

/* ---------- 筛选栏 ---------- */
.filters {
  display: flex; flex-wrap: wrap; gap: 10px; align-items: center;
  background: var(--card); border-radius: var(--radius); padding: 14px 16px; box-shadow: var(--shadow);
  margin-bottom: 18px;
}
/* 桌面端筛选控件并排；原来的 width:100% 会把每个控件挤成整行 */
.filters .field { margin: 0; min-width: 130px; width: auto; flex: 1 1 180px; }
.filters .spacer { flex: 1; }

/* ---------- 表单元素 ---------- */
.field {
  width: 100%;
  border: 1px solid var(--hairline);
  background: #fff;
  border-radius: 12px;
  padding: 11px 14px;
  font-size: 15px; color: var(--text);
  font-family: inherit;
  outline: none; transition: border-color .15s, box-shadow .15s;
}
.field:focus { border-color: var(--blue); box-shadow: 0 0 0 4px rgba(0,113,227,.12); }
textarea.field { resize: vertical; min-height: 88px; line-height: 1.5; }
select.field { appearance: none; background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'><path d='M2 4l4 4 4-4' fill='none' stroke='%2386868b' stroke-width='1.4'/></svg>"); background-repeat: no-repeat; background-position: right 14px center; padding-right: 34px; }
label.field-label { display: block; font-size: 13px; color: var(--text-2); margin-bottom: 6px; }

/* ---------- 按钮 ---------- */
.btn-primary {
  background: var(--blue); color: #fff; border: none; cursor: pointer;
  font-size: 15px; font-weight: 500; font-family: inherit;
  padding: 10px 20px; border-radius: 980px; transition: .15s;
}
.btn-primary:hover { background: var(--blue-dark); }
.btn-primary:disabled { opacity: .5; cursor: default; }
.btn-block { width: 100%; padding: 12px; font-size: 16px; }
.btn-ghost {
  background: transparent; color: var(--blue); border: none; cursor: pointer;
  font-size: 14px; font-family: inherit; padding: 6px 10px; border-radius: 980px;
}
.btn-ghost:hover { background: rgba(0,113,227,.08); }
.btn-secondary {
  background: #fff; color: var(--text); border: 1px solid var(--hairline); cursor: pointer;
  font-size: 14px; font-family: inherit; padding: 9px 18px; border-radius: 980px; transition: .15s;
}
.btn-secondary:hover { border-color: var(--text-3); }

/* ---------- 表格 ---------- */
.table-card { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
thead th {
  text-align: left; font-size: 12px; font-weight: 500; color: var(--text-3);
  padding: 14px 18px; border-bottom: 1px solid var(--hairline-soft);
  background: #fbfbfd; white-space: nowrap;
}
tbody td { padding: 15px 18px; border-bottom: 1px solid var(--hairline-soft); font-size: 14px; vertical-align: top; }
tbody tr:last-child td { border-bottom: none; }
tbody tr:hover { background: #fafafc; }
.mono-num { font-variant-numeric: tabular-nums; }
.empty { padding: 56px 18px; text-align: center; color: var(--text-3); font-size: 14px; }

/* ---------- 标签 / 徽章 ---------- */
.badge {
  display: inline-block; font-size: 12px; padding: 3px 10px; border-radius: 980px;
  background: rgba(0,113,227,.1); color: var(--blue); font-weight: 500;
}
.badge.ok { background: rgba(52,168,83,.12); color: var(--green); }
.badge.warn { background: rgba(255,159,10,.14); color: var(--orange); }
.badge.danger { background: rgba(255,59,48,.12); color: var(--red); }
.badge.muted { background: rgba(134,134,139,.14); color: var(--text-3); }

/* ---------- 督查卡片 ---------- */
.sup-list { display: grid; grid-template-columns: repeat(2, 1fr); gap: 16px; }
.sup-card { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: 20px 22px; }
.sup-card .row1 { display: flex; align-items: center; gap: 10px; margin-bottom: 4px; }
.sup-card .client { font-size: 17px; font-weight: 600; }
.sup-card .meta { font-size: 13px; color: var(--text-3); margin-bottom: 12px; }
.sup-card .last { font-size: 13px; color: var(--text-2); margin-bottom: 14px; }
.timeline { border-top: 1px solid var(--hairline-soft); padding-top: 14px; margin-top: 4px; }
.tl-item { position: relative; padding: 0 0 14px 18px; }
.tl-item::before {
  content: ''; position: absolute; left: 3px; top: 5px; width: 7px; height: 7px;
  border-radius: 50%; background: var(--blue);
}
.tl-item::after {
  content: ''; position: absolute; left: 6px; top: 12px; bottom: 0; width: 1px; background: var(--hairline-soft);
}
.tl-item:last-child::after { display: none; }
.tl-meta { font-size: 12px; color: var(--text-3); margin-bottom: 3px; }
.tl-text { font-size: 14px; color: var(--text); white-space: pre-wrap; }
.follow-form { display: flex; gap: 8px; margin-top: 12px; }
.follow-form .field { flex: 1; }

/* ---------- 弹窗 ---------- */
.modal-mask {
  position: fixed; inset: 0; background: rgba(0,0,0,.32);
  display: flex; align-items: flex-start; justify-content: center;
  padding: 6vh 16px; z-index: 100; overflow-y: auto;
}
.modal {
  background: #fff; border-radius: 22px; width: 560px; max-width: 100%;
  box-shadow: 0 20px 60px rgba(0,0,0,.25); padding: 30px 32px 28px;
  animation: pop .18s ease;
}
@keyframes pop { from { transform: translateY(8px) scale(.98); opacity: 0; } to { transform: none; opacity: 1; } }
.modal h2 { font-size: 22px; font-weight: 600; margin: 0 0 22px; letter-spacing: -0.02em; }
.modal .form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px 16px; }
.modal .form-grid .full { grid-column: 1 / -1; }
.modal-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 24px; }
.detail-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px 24px; }
.detail-item .k { font-size: 12px; color: var(--text-3); margin-bottom: 3px; }
.detail-item .v { font-size: 15px; }
.detail-item.full { grid-column: 1 / -1; }
.detail-desc {
  grid-column: 1 / -1; background: #f5f5f7; border-radius: 12px; padding: 14px 16px;
  font-size: 14px; color: var(--text); white-space: pre-wrap; line-height: 1.6;
}

/* ---------- Toast ---------- */
.toast-root { position: fixed; left: 50%; bottom: 36px; transform: translateX(-50%); z-index: 200; display: flex; flex-direction: column; gap: 10px; align-items: center; }
.toast {
  background: rgba(29,29,31,.92); color: #fff; font-size: 14px;
  padding: 11px 20px; border-radius: 12px; box-shadow: 0 8px 24px rgba(0,0,0,.25);
  animation: toastIn .2s ease;
}
.toast.err { background: rgba(255,59,48,.95); }
@keyframes toastIn { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

/* ---------- 财务大屏 ---------- */
.dash-cards { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; margin-bottom: 18px; }
.dash-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.dash-panel { background: #fff; border-radius: 18px; padding: 20px 22px; box-shadow: 0 1px 3px rgba(0,0,0,.06); }
.dash-panel-title { font-size: 15px; font-weight: 600; margin-bottom: 16px; letter-spacing: -0.01em; }
.dist-list { display: flex; flex-direction: column; gap: 12px; }
.dist-row { display: grid; grid-template-columns: 110px 1fr auto; align-items: center; gap: 12px; }
.dist-name { font-size: 13px; color: var(--text-2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dist-bar { height: 10px; background: #f0f0f2; border-radius: 6px; overflow: hidden; }
.dist-fill { height: 100%; background: var(--blue); border-radius: 6px; }
.dist-num { font-size: 13px; color: var(--text); white-space: nowrap; font-variant-numeric: tabular-nums; }

/* ---------- 客户总览（打通） ---------- */
.hint-text { font-size: 13px; color: var(--text-3); }
.ov-card { background: #fff; border-radius: 18px; padding: 18px 22px; box-shadow: 0 1px 3px rgba(0,0,0,.06); margin-bottom: 14px; }
.ov-head { display: flex; align-items: center; gap: 10px; margin-bottom: 12px; }
.ov-name { font-size: 18px; font-weight: 600; letter-spacing: -0.01em; }
.ov-tags { font-size: 12px; color: var(--text-3); background: #f5f5f7; padding: 3px 10px; border-radius: 20px; }
.ov-section { margin-top: 10px; }
.ov-sec-title { font-size: 12px; color: var(--text-3); margin-bottom: 6px; font-weight: 600; }
.ov-row { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 14px; font-size: 13px; color: var(--text-2); padding: 7px 0; border-top: 1px solid #f0f0f2; }
.ov-money { color: var(--text); }
.ov-money b { color: var(--text); }
.ov-team { color: var(--text-3); }
.ov-empty { font-size: 13px; color: var(--text-3); padding: 6px 0; }
.link-mini { font-size: 12px; color: var(--blue); margin-left: 6px; }
.client-head .link-mini { margin-left: auto; }

/* ---------- 管理页 ---------- */
.manage-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.manage-panel { background: #fff; border-radius: 18px; padding: 20px 22px; box-shadow: 0 1px 3px rgba(0,0,0,.06); }
.manage-add { display: flex; gap: 10px; margin-bottom: 14px; }
.manage-add .field { flex: 1; }
.mgrid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px 14px; margin-bottom: 16px; }
.mgrid .full { grid-column: 1 / -1; }
.manage-list { display: flex; flex-direction: column; gap: 8px; }
.row-line { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 10px 14px; background: #f5f5f7; border-radius: 12px; font-size: 14px; }
.u-main { display: flex; flex-direction: column; }
.u-sub { font-size: 12px; color: var(--text-3); }
.u-actions { display: flex; gap: 8px; }
.btn-mini { border: 1px solid #d2d2d7; background: #fff; color: var(--text); border-radius: 20px; padding: 5px 12px; font-size: 13px; cursor: pointer; }
.btn-mini:hover { background: #f5f5f7; }
.btn-danger-mini { border: 1px solid #ffd2cf; background: #fff; color: #ff3b30; border-radius: 20px; padding: 5px 12px; font-size: 13px; cursor: pointer; }
.btn-danger-mini:hover { background: #fff5f4; }
.btn-danger-mini:disabled { opacity: .4; cursor: not-allowed; }

/* ---------- 手机版优化 ---------- */
@media (max-width: 760px) {
  .stats-row { grid-template-columns: repeat(2, 1fr); }
  .stats-row .stat-card.accent-risk, .stats-row .stat-card.accent-closed, .stats-row .stat-card.accent-complaint { box-shadow: var(--shadow); }
  .stats-row .stat-card.clickable.active { box-shadow: 0 0 0 2px var(--blue); }
  .stats-row .stat-card.clickable.active.accent-risk,
  .stats-row .stat-card.clickable.active.accent-complaint { box-shadow: 0 0 0 2px var(--red); }
  .sup-list { grid-template-columns: 1fr; }
  .modal .form-grid, .detail-grid { grid-template-columns: 1fr; }
  .dash-cards { grid-template-columns: repeat(2, 1fr); }
  .dash-grid, .manage-grid { grid-template-columns: 1fr; }
  .dist-row { grid-template-columns: 80px 1fr auto; }

  /* 输入字号 ≥16px，避免 iOS 聚焦时自动放大页面 */
  .field, textarea.field, select.field { font-size: 16px; }
  .login-card { padding: 44px 26px 36px; border-radius: 24px; }
  .login-title { font-size: 23px; }
  .login-form { gap: 14px; }

  /* 顶栏：品牌+用户一行，页签单独一行可横滑 */
  .topbar { flex-wrap: wrap; height: auto; padding: 10px 14px; gap: 8px 12px; }
  .brand { font-size: 16px; }
  .userbox { order: 2; margin-left: auto; }
  .user-name { font-size: 12px; }
  .tabs {
    order: 3; width: 100%; margin-left: 0; overflow-x: auto;
    -webkit-overflow-scrolling: touch; scrollbar-width: none; white-space: nowrap; padding-bottom: 2px;
  }
  .tabs::-webkit-scrollbar { display: none; }
  .tabs .tab { padding: 8px 12px; flex: 0 0 auto; }

  /* 内容收窄留白 */
  .content { padding: 20px 16px 48px; }
  .section-title { font-size: 22px; }
  .section-head { flex-wrap: wrap; gap: 10px; }
  .section-head .hint-text { width: 100%; }

  /* 表格横向滚动，避免挤压 */
  table { min-width: 640px; }

  /* 跟进表单窄屏竖排 */
  .follow-form { flex-direction: column; align-items: stretch; }
  .follow-form .field { max-width: none; }
  .follow-form [data-role="add"] { width: 100%; }

  /* 弹窗在小屏更贴边 */
  .modal { padding: 24px 20px 22px; border-radius: 20px; }
  .filters .field { min-width: 0; flex: 1 1 100%; }
}

/* 超窄屏（≤380px）登录与卡片进一步收紧 */
@media (max-width: 380px) {
  .login-card { padding: 36px 18px 30px; }
  .dash-cards, .stats-row { grid-template-columns: 1fr; }
  .content { padding: 16px 12px 40px; }
}
