/* ==========================================================================
   接单管家 · 工作台（网页版后台）
   风格：现代 SaaS 后台 / 中性灰 + 品牌橙 / 响应式三档断点
   ========================================================================== */
:root {
  color-scheme: light;
  --bg: #F6F7FB;
  --surface: #ffffff;
  --surface-2: #EFF2F8;
  --surface-3: #E9EDF5;
  --border: #E3E7F0;
  --border-2: #D7DCE8;
  --text: #1B2233;
  --text-2: #4e5561;
  --text-3: #8A93A6;
  --primary: #4A5AF0;
  --primary-strong: #3A46C4;
  --primary-soft: #E9EBFC;
  --success: #27AE60;
  --success-soft: #E8F8EE;
  --warning: #E67E22;
  --warning-soft: #FCF0E6;
  --danger: #E74C3C;
  --danger-soft: #FDE8E8;
  --info: #1971c2;
  --info-soft: #e7f5ff;
  --radius: 10px;
  --radius-sm: 6px;
  --shadow: 0 1px 2px rgba(16, 24, 40, .05), 0 1px 3px rgba(16, 24, 40, .08);
  --shadow-lg: 0 12px 32px rgba(16, 24, 40, .14);
  --font: "PingFang SC", "Microsoft YaHei", "Hiragino Sans GB", "Helvetica Neue", system-ui, sans-serif;
  --mono: "SF Mono", "Cascadia Code", Consolas, monospace;
  --sidebar-w: 232px;
  --sidebar-w-collapsed: 72px;
  --topbar-h: 60px;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html { -webkit-text-size-adjust: 100%; }
body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.6;
}
a { color: var(--primary); text-decoration: none; }
a:hover { opacity: .8; }
button { font-family: inherit; }

.app { display: flex; min-height: 100vh; }
[hidden] { display: none !important; }

/* ================= 侧边栏 ================= */
.sidebar {
  position: fixed; inset: 0 auto 0 0;
  width: var(--sidebar-w);
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex; flex-direction: column;
  z-index: 100;
  transition: transform .28s ease;
}
.side-brand {
  display: flex; align-items: center; gap: 10px;
  height: var(--topbar-h);
  padding: 0 20px;
  border-bottom: 1px solid var(--border);
  color: var(--text); font-weight: 600; font-size: 15px;
}
.side-brand:hover { opacity: 1; }
.seal {
  width: 32px; height: 32px; flex: none;
  border-radius: 8px;
  background: linear-gradient(180deg, #6B7BFF 0%, #3A46C4 100%);
  color: #fff; font-weight: 700; font-size: 16px;
  display: flex; align-items: center; justify-content: center;
}
.badge {
  font-size: 10px; font-weight: 600; letter-spacing: .5px;
  color: var(--primary); background: var(--primary-soft);
  border-radius: 4px; padding: 2px 6px;
}
.side-nav { flex: 1; overflow-y: auto; padding: 12px 10px 20px; }
.nav-group { margin-bottom: 14px; }
.nav-group-title {
  font-size: 11px; color: var(--text-3);
  letter-spacing: 1px; padding: 0 10px 6px; user-select: none;
}
.nav-item {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 10px; margin-bottom: 2px;
  border-radius: 8px; color: var(--text-2);
  font-size: 13.5px; cursor: pointer; border: none; background: none;
  width: 100%; text-align: left;
  text-decoration: none; box-sizing: border-box;
  transition: background .15s ease, color .15s ease;
}
.nav-item svg { width: 17px; height: 17px; flex: none; stroke: currentColor; }
.nav-item:hover { background: var(--surface-3); color: var(--text); opacity: 1; }
.nav-item.active { background: var(--primary-soft); color: var(--primary-strong); font-weight: 600; }
.nav-item .count {
  margin-left: auto; font-size: 11px; font-weight: 600;
  color: var(--text-3); background: var(--surface-3);
  border-radius: 10px; padding: 1px 7px;
}
.nav-item.active .count { color: var(--primary); background: #E4E9FD; }
.side-foot {
  padding: 12px 20px; border-top: 1px solid var(--border);
  font-size: 11.5px; color: var(--text-3);
  display: flex; align-items: center; gap: 7px;
}
.dot { width: 7px; height: 7px; border-radius: 50%; background: var(--success); }
.dot.offline { background: var(--danger); }
.dot.busy { background: var(--warning); }

.mask {
  position: fixed; inset: 0; background: rgba(16, 24, 40, .45);
  z-index: 90; opacity: 0; pointer-events: none; transition: opacity .25s ease;
}
.mask.show { opacity: 1; pointer-events: auto; }

/* ================= 主区域 ================= */
.main { flex: 1; margin-left: var(--sidebar-w); min-width: 0; display: flex; flex-direction: column; }
.topbar {
  position: sticky; top: 0; z-index: 50;
  height: var(--topbar-h);
  background: color-mix(in srgb, var(--surface) 88%, transparent);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; gap: 14px;
  padding: 0 24px;
}
.icon-btn.hamburger { display: none; }
.icon-btn {
  width: 34px; height: 34px; border-radius: 8px;
  border: 1px solid var(--border); background: var(--surface);
  font-size: 15px; color: var(--text-2); cursor: pointer;
  display: flex; align-items: center; justify-content: center;
}
.icon-btn:hover { background: var(--surface-3); }
.top-title { font-size: 15px; font-weight: 600; display: inline-flex; align-items: baseline; gap: 8px; }
.top-title-sub { font-size: 12px; font-weight: 400; color: var(--text-3); white-space: nowrap; }
.top-actions { margin-left: auto; display: flex; align-items: center; gap: 12px; }
.top-link { font-size: 13px; color: var(--text-2); }
.top-link:hover { color: var(--primary); opacity: 1; }
.avatar {
  width: 34px; height: 34px; border-radius: 50%;
  background: var(--primary); color: #fff;
  font-size: 13px; font-weight: 600;
  display: flex; align-items: center; justify-content: center;
  cursor: default; user-select: none;
}
.page { padding: 24px; width: 100%; }

/* ================= 通用组件 ================= */
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 20px; flex-wrap: wrap; }
.page-title { font-size: 20px; font-weight: 700; }
.page-sub { font-size: 13px; color: var(--text-3); margin-top: 2px; }

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.card-head {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 14px 18px; border-bottom: 1px solid var(--border);
}
.card-title { font-size: 14px; font-weight: 600; }
.card-body { padding: 18px; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  height: 34px; padding: 0 14px;
  border: 1px solid var(--border-2); border-radius: 8px;
  background: var(--surface); color: var(--text-2);
  font-size: 13px; font-weight: 500; cursor: pointer;
  transition: all .15s ease; white-space: nowrap;
}
.btn:hover { border-color: var(--primary); color: var(--primary); opacity: 1; }
.btn.primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn.primary:hover { background: var(--primary-strong); color: #fff; }
.btn.danger { color: var(--danger); border-color: rgba(231, 76, 60, .22); }
.btn.danger:hover { background: var(--danger-soft); border-color: var(--danger); color: var(--danger); }
.btn.sm { height: 28px; padding: 0 6px; font-size: 12px; border-radius: 6px; }
.btn:disabled { opacity: .55; cursor: not-allowed; }

.input, .select, .textarea {
  width: 100%; height: 36px;
  border: 1px solid var(--border-2); border-radius: 8px;
  padding: 0 12px; font-size: 13.5px; color: var(--text);
  background: var(--surface); outline: none;
  transition: border-color .15s ease, box-shadow .15s ease;
  font-family: inherit;
}
.textarea { height: auto; min-height: 88px; padding: 10px 12px; resize: vertical; }
.input:focus, .select:focus, .textarea:focus {
  border-color: var(--primary); box-shadow: 0 0 0 3px rgba(74, 90, 240, .14);
}
.input::placeholder, .textarea::placeholder { color: var(--text-3); }
.select { appearance: none; 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='%238a919c' stroke-width='2.4' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 10px center; padding-right: 32px; cursor: pointer; }

.toolbar { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 16px; }
.search-box { position: relative; flex: 1; min-width: 220px; max-width: 360px; }
.search-box .input { padding-left: 34px; }
.search-box svg { position: absolute; left: 11px; top: 50%; transform: translateY(-50%); width: 15px; height: 15px; stroke: var(--text-3); pointer-events: none; }

/* 表格 */
.table-wrap { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; font-size: 13.5px; min-width: 640px; table-layout: fixed; }
.table th {
  text-align: left; font-weight: 600; color: var(--text-2);
  background: var(--surface-2); padding: 10px 16px;
  border-bottom: 1px solid var(--border); white-space: nowrap;
  font-size: 12.5px; letter-spacing: .3px;
}
.table td { padding: 12px 16px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.table tbody tr:hover { background: var(--surface-2); }
.table tbody tr:last-child td { border-bottom: none; }
.table .num { font-family: var(--mono); font-variant-numeric: tabular-nums; }
/* 列表页通用：末列（操作等）固定宽，fixed 布局下中间列等分，首尾留白对称 */
.table th:last-child,
.table td:last-child { width: 184px; }
/* 客户列表：序号列固定宽、操作列贴合按钮组宽度（避免右侧大空白） */
.table.table-customers th:first-child,
.table.table-customers td:first-child { width: 64px; }
.table.table-customers th:last-child,
.table.table-customers td:last-child { width: 112px; }
.row-actions { display: flex; gap: 4px; }

/* 标签 */
.tag {
  display: inline-flex; align-items: center; gap: 4px;
  font-size: 12px; font-weight: 500;
  padding: 2px 9px; border-radius: 20px; white-space: nowrap;
}
.tag.gray { background: var(--surface-3); color: var(--text-2); }
.tag.orange { background: var(--primary-soft); color: var(--primary-strong); }
.tag.green { background: var(--success-soft); color: var(--success); }
.tag.blue { background: var(--info-soft); color: var(--info); }
.tag.red { background: var(--danger-soft); color: var(--danger); }
.tag.yellow { background: var(--warning-soft); color: var(--warning); }
/* 客户列表分类列：普通文本 + App 同款颜色，无气泡 */
.cate-text { font-weight: 600; }

/* 统计卡片 */
.stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; margin-bottom: 20px; }
.stat {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 16px 18px; box-shadow: var(--shadow);
  display: flex; flex-direction: column; gap: 6px; min-width: 0;
}
.stat-label { font-size: 12.5px; color: var(--text-3); display: flex; align-items: center; gap: 6px; }
.stat-label svg { width: 14px; height: 14px; stroke: currentColor; }
.stat-value { font-size: 24px; font-weight: 700; font-family: var(--mono); font-variant-numeric: tabular-nums; line-height: 1.2; }
.stat-trend { font-size: 12px; color: var(--text-3); }
.stat-trend b { font-weight: 600; }
.stat-trend.up { color: var(--success); }
.stat-trend.down { color: var(--danger); }

/* 柱状图（纯 CSS） */
.bar-chart { display: flex; align-items: flex-end; gap: 10px; height: 190px; padding: 8px 4px 0; }
.bar-col { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 8px; height: 100%; justify-content: flex-end; }
.bar {
  width: min(34px, 62%); border-radius: 6px 6px 2px 2px;
  background: linear-gradient(180deg, #5A68F5 0%, var(--primary) 100%);
  min-height: 3px; transition: height .4s ease;
  position: relative;
}
.bar:hover { filter: brightness(.94); }
.bar .bar-val {
  position: absolute; top: -20px; left: 50%; transform: translateX(-50%);
  font-size: 10.5px; color: var(--text-2); font-family: var(--mono); white-space: nowrap; opacity: 0; transition: opacity .15s;
}
.bar-col:hover .bar-val { opacity: 1; }
.bar-label { font-size: 11.5px; color: var(--text-3); }

/* 空状态 / 提示 */
.empty { text-align: center; padding: 48px 16px; color: var(--text-3); }
.empty svg { width: 44px; height: 44px; stroke: #c9cdd4; margin-bottom: 12px; }
.empty p { font-size: 13.5px; }
.hint { font-size: 12px; color: var(--text-3); line-height: 1.7; }
.hint b { color: var(--text-2); font-weight: 600; }

/* 弹窗 */
.modal-mask {
  position: fixed; inset: 0; background: rgba(16, 24, 40, .5);
  z-index: 200; display: flex; align-items: center; justify-content: center;
  padding: 20px; opacity: 0; pointer-events: none; transition: opacity .2s ease;
}
.modal-mask.show { opacity: 1; pointer-events: auto; }
.modal {
  width: min(520px, 100%); max-height: 88vh; overflow-y: auto;
  background: var(--surface); border-radius: 14px; box-shadow: var(--shadow-lg);
  transform: translateY(8px); transition: transform .2s ease;
}
.modal-mask.show .modal { transform: translateY(0); }
.modal-head { display: flex; align-items: center; justify-content: space-between; padding: 16px 20px; border-bottom: 1px solid var(--border); }
.modal-title { font-size: 15px; font-weight: 600; }
.modal-close { border: none; background: none; font-size: 18px; color: var(--text-3); cursor: pointer; line-height: 1; }
.modal-close:hover { color: var(--text); }
.modal-body { padding: 20px; }
.modal-foot { padding: 14px 20px; border-top: 1px solid var(--border); display: flex; justify-content: flex-end; gap: 10px; }

.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.form-item { display: flex; flex-direction: column; gap: 6px; }
.form-item.full { grid-column: 1 / -1; }
.form-label { font-size: 12.5px; color: var(--text-2); font-weight: 500; }
.region-pop {
  position: absolute; z-index: 400;
  top: calc(100% + 6px); left: 0; right: 0;
  min-width: 220px;
  display: flex; flex-direction: column;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  box-shadow: 0 8px 30px rgba(0, 0, 0, 0.14);
  overflow: hidden;
}
.region-pop-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 8px 10px; border-bottom: 1px solid var(--border);
}
.region-title { font-size: 13px; font-weight: 600; color: var(--text); }
.region-back, .region-close {
  border: 0; background: none; cursor: pointer;
  color: var(--text-2); font-size: 14px; line-height: 1; padding: 2px 8px;
}
.region-back:hover, .region-close:hover { color: var(--text); }
.region-items { max-height: 280px; overflow-y: auto; }
.region-item {
  display: block; width: 100%; text-align: left;
  border: 0; background: none; cursor: pointer;
  padding: 10px 14px; font-size: 13.5px; color: var(--text);
  border-bottom: 1px solid var(--border);
}
.region-item:hover { background: var(--surface-3); }
.region-empty { padding: 18px; text-align: center; color: var(--text-3); font-size: 13px; }

/* Toast */
.toast-wrap { position: fixed; top: 72px; left: 50%; transform: translateX(-50%); z-index: 300; display: flex; flex-direction: column; gap: 8px; align-items: center; }
.toast {
  background: var(--text); color: #fff; font-size: 13px;
  padding: 9px 18px; border-radius: 10px; box-shadow: var(--shadow-lg);
  animation: toastIn .25s ease; white-space: nowrap;
}
.toast.err { background: var(--danger); }
@keyframes toastIn { from { opacity: 0; transform: translateY(-8px); } to { opacity: 1; transform: none; } }

/* 详情/状态卡片 */
.two-col { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; margin-bottom: 20px; }
.two-col .card { min-width: 0; }
.list-line { display: flex; justify-content: space-between; align-items: center; padding: 10px 0; border-bottom: 1px dashed var(--border); font-size: 13.5px; }
.list-line:last-child { border-bottom: none; }
.list-line .k { color: var(--text-2); }
.list-line .v { font-weight: 600; font-variant-numeric: tabular-nums; }

.balance-card {
  background: linear-gradient(135deg, #4A5AF0 0%, #3A46C4 100%);
  color: #fff; border-radius: var(--radius); padding: 22px;
  display: flex; flex-direction: column; gap: 8px; box-shadow: var(--shadow);
}
.balance-card .b-label { font-size: 12.5px; opacity: .85; }
.balance-card .b-value { font-size: 30px; font-weight: 700; font-family: var(--mono); font-variant-numeric: tabular-nums; }
.balance-card .b-sub { font-size: 12px; opacity: .85; }

.qr-box {
  width: 148px; height: 148px; border: 1px solid var(--border);
  border-radius: 10px; padding: 10px; background: #fff;
  display: flex; align-items: center; justify-content: center;
}
.qr-box svg { width: 100%; height: 100%; }

/* 套餐卡 */
.plan-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; }
.plan { border: 1px solid var(--border); border-radius: 12px; padding: 18px; background: var(--surface); display: flex; flex-direction: column; gap: 10px; }
.plan.hot { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(74, 90, 240, .12); position: relative; }
.plan-name { font-size: 14px; font-weight: 600; }
.plan-price { font-size: 22px; font-weight: 700; font-family: var(--mono); }
.plan-price small { font-size: 12px; color: var(--text-3); font-weight: 500; }
.plan-feat { font-size: 12.5px; color: var(--text-2); list-style: none; display: flex; flex-direction: column; gap: 5px; }
.plan-feat li { display: flex; gap: 6px; align-items: flex-start; }
.plan-feat svg { width: 14px; height: 14px; stroke: var(--success); flex: none; margin-top: 2px; }
.plan .btn { margin-top: auto; }

/* 专业版支付方式选择 */
.pay-method-list { display: flex; flex-direction: column; gap: 8px; }
.pay-method { border: 1px solid var(--border); border-radius: 10px; padding: 12px 14px; cursor: pointer; transition: border-color .15s, background .15s; }
.pay-method:hover { border-color: var(--primary); background: rgba(74, 90, 240, .04); }
.pay-method .pm-name { font-size: 14px; font-weight: 600; }
.pay-method .pm-sub { font-size: 12px; color: var(--text-3); margin-top: 2px; }

/* ================= 登录 / 注册页 ================= */
#loginView {
  min-height: 100vh;
  display: flex; align-items: center; justify-content: center;
  padding: 24px 16px;
  background:
    radial-gradient(1000px 480px at 85% -10%, rgba(74, 90, 240, .16), transparent 60%),
    radial-gradient(800px 420px at -10% 110%, rgba(107, 123, 255, .18), transparent 60%),
    linear-gradient(160deg, #F6F7FB 0%, #f2f3f6 100%);
}
.login-card {
  width: min(400px, 100%);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  box-shadow: var(--shadow-lg);
  padding: 30px 30px 26px;
}
.login-brand { display: flex; align-items: center; gap: 12px; margin-bottom: 8px; }
.login-brand .seal { width: 40px; height: 40px; border-radius: 10px; font-size: 20px; }
.login-title { font-size: 20px; font-weight: 700; }
.login-sub { font-size: 12.5px; color: var(--text-3); margin-bottom: 20px; }
.login-tabs { display: flex; gap: 6px; background: var(--surface-3); border-radius: 10px; padding: 4px; margin-bottom: 18px; }
.login-tab {
  flex: 1; text-align: center; height: 34px; line-height: 34px;
  border: none; background: none; border-radius: 8px;
  font-size: 13.5px; color: var(--text-2); cursor: pointer;
}
.login-tab.active { background: var(--surface); color: var(--primary-strong); font-weight: 600; box-shadow: var(--shadow); }
.login-form { display: flex; flex-direction: column; gap: 14px; }
.login-form .form-item { gap: 7px; }
.login-form .input { height: 42px; font-size: 14px; }
.login-error {
  background: var(--danger-soft); color: var(--danger);
  font-size: 12.5px; border-radius: 8px; padding: 9px 12px;
  display: none; line-height: 1.5;
}
.login-error.show { display: block; }
.login-submit {
  height: 42px; font-size: 14.5px; font-weight: 600;
  border: none; border-radius: 10px; cursor: pointer;
  background: var(--primary); color: #fff;
  transition: background .15s ease;
}
.login-submit:hover { background: var(--primary-strong); }
.login-submit:disabled { opacity: .6; cursor: not-allowed; }
.login-tip { margin-top: 16px; font-size: 12px; color: var(--text-3); text-align: center; line-height: 1.7; }
.login-foot { margin-top: 22px; padding-top: 14px; border-top: 1px solid var(--border); font-size: 11.5px; color: var(--text-3); display: flex; justify-content: center; gap: 14px; }
.login-foot a { font-size: 11.5px; }

/* 分段 / 筛选 */
.seg { display: inline-flex; gap: 4px; background: var(--surface-3); border-radius: 8px; padding: 3px; }
.seg button {
  border: none; background: none; height: 28px; padding: 0 12px;
  border-radius: 6px; font-size: 12.5px; color: var(--text-2); cursor: pointer;
}
.seg button.active { background: var(--surface); color: var(--primary-strong); font-weight: 600; box-shadow: var(--shadow); }
.chip {
  display: inline-flex; align-items: center; height: 28px; padding: 0 12px;
  border: 1px solid var(--border-2); background: var(--surface); color: var(--text-2);
  border-radius: 20px; font-size: 12.5px; cursor: pointer;
}
.chip.active { border-color: var(--primary); background: var(--primary-soft); color: var(--primary-strong); font-weight: 600; }

/* 详情键值 */
.kv-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px 22px; }
.kv { display: flex; flex-direction: column; gap: 2px; }
.kv .k { font-size: 11.5px; color: var(--text-3); }
.kv .v { font-size: 13.5px; font-weight: 600; }

/* 设置行 */
.status-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 13px 0; border-bottom: 1px solid var(--border); }
.status-row:last-child { border-bottom: none; }
.status-row .l { display: flex; flex-direction: column; gap: 2px; }
.status-row .t { font-size: 13.5px; font-weight: 600; }
.status-row .d { font-size: 12px; color: var(--text-3); }

/* 平板档（≤1023px）：内容整体收窄、栅格降列，表格列宽保持弹性 */
@media (max-width: 1023.98px) {
  :root { --topbar-h: 56px; }
  .topbar { padding: 0 14px; }
  .page { padding: 16px; }
  .plan-grid { grid-template-columns: repeat(2, 1fr); }
  .stats { grid-template-columns: repeat(2, 1fr); }
  .two-col { grid-template-columns: 1fr; }
  .table { min-width: 0; }
  .table th, .table td { padding-left: 10px; padding-right: 10px; }
  .table th:last-child, .table td:last-child { width: 170px; }
  .table.table-customers th:first-child, .table.table-customers td:first-child { width: 48px; }
}

@media (max-width: 767.98px) {
  .sidebar { transform: translateX(-100%); width: var(--sidebar-w); }
  .sidebar.open { transform: translateX(0); box-shadow: var(--shadow-lg); }
  .main { margin-left: 0; }
  .icon-btn.hamburger { display: flex; }
}

/* 手机档（≤640px）：列表表格整体切换为卡片式布局，零横向滚动 */
@media (max-width: 640px) {
  .stats { grid-template-columns: 1fr; gap: 10px; }
  .plan-grid { grid-template-columns: 1fr; }
  .form-grid { grid-template-columns: 1fr; }
  .page-title { font-size: 18px; }
  .top-link { display: none; }
  .bar-chart { height: 150px; gap: 6px; }
  .bar-label { font-size: 10.5px; }
  .login-card { padding: 24px 20px 20px; }
  .kv-grid { grid-template-columns: 1fr; }
  .filter-item { flex-wrap: wrap; }
  .filter-item .sel-fill { width: 100%; }

  /* --- 表格 → 卡片：每行渲染为一张卡片 --- */
  .table-wrap { overflow-x: visible; }
  .table { display: block; width: 100%; min-width: 0; }
  .table thead { display: none; }
  .table tbody { display: block; }
  .table tbody tr {
    display: block;
    margin-bottom: 12px;
    padding: 2px 14px 12px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
  }
  .table tbody tr:last-child { margin-bottom: 0; }
  .table tbody tr:hover { background: var(--surface); }
  .table tbody tr td {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 6px 14px;
    padding: 11px 0;
    border-bottom: 1px solid var(--border);
    text-align: right;
    word-break: break-word;
  }
  .table tbody tr:last-child td { border-bottom: 1px solid var(--border); }
  .table tbody tr td::before {
    content: attr(data-label);
    flex: none;
    font-size: 12px;
    color: var(--text-2);
    letter-spacing: .2px;
  }
  /* 主标题字段（首列 / 客户名称）在卡片内适度放大 */
  .table tbody tr td:first-child b { font-size: 14.5px; }
  /* 标签列：多枚 chip 允许折行 */
  .table tbody tr td .tag-chip { flex-wrap: wrap; }
  /* 操作列（无 data-label）：按钮整行铺满，置于卡片底部 */
  .table tbody tr td:not([data-label]) {
    display: block;
    padding: 11px 0 2px;
    border-bottom: none;
    text-align: left;
  }
  .table tbody tr td:not([data-label])::before { content: none; }
  .table tbody tr td .row-actions { display: flex; }
  .table tbody tr td .row-actions .btn { flex: 1 1 auto; min-width: 0; }
  .table tbody tr td > .btn { width: 100%; }
  /* 空态行：整卡居中显示，不渲染字段标签 */
  .table tbody tr td[colspan] {
    display: block;
    padding: 22px 0;
    border-bottom: none;
    text-align: center;
  }
  .table tbody tr td[colspan]::before { content: none; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}

/* ===== 分段按钮（seg-btn） ===== */
.seg-btn { border: 0; background: transparent; padding: 6px 12px; border-radius: 6px; font-size: 12.5px; color: var(--text-2, #666); cursor: pointer; white-space: nowrap; }
.seg-btn:hover { color: var(--primary, #4A5AF0); }
.seg-btn.active { background: var(--surface, #fff); color: var(--primary-strong, #4A5AF0); font-weight: 600; box-shadow: 0 1px 3px rgba(0,0,0,.08); }

/* ===== 客户页 Tab（客户列表 / 标签维护） ===== */
.tabs { display: flex; gap: 6px; background: var(--surface-3); border-radius: 10px; padding: 4px; margin-bottom: 16px; max-width: 320px; }
.tab { flex: 1; text-align: center; height: 34px; line-height: 34px; border: none; background: none; border-radius: 8px; font-size: 13.5px; color: var(--text-2); cursor: pointer; }
.tab.active { background: var(--surface); color: var(--primary-strong); font-weight: 600; box-shadow: var(--shadow); }

/* ===== 客户筛选（搜索客户 / 联系人 / 行业 / 来源） ===== */
.filter-bar { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 14px; }
.filter-grid { display: flex; flex-wrap: wrap; gap: 8px; width: 100%; }
@media (min-width: 1280px) {
  .filter-bar { flex-wrap: nowrap; }
  .filter-grid { display: grid; grid-template-columns: 105px 105px 225px 225px 105px auto 1fr; gap: 6px; width: 100%; }
  .filter-grid .filter-item .input { flex: 1; width: auto; max-width: none; }
  .filter-grid .filter-item .select:not(.sel-fill) { width: auto; max-width: 220px; }
}
.filter-item { display: flex; gap: 8px; align-items: center; flex: 0 0 auto; }
.filter-item .input { flex: none; width: 180px; min-width: 0; max-width: none; }
.filter-item .sel-fill { width: 118px; flex: none; }
.filter-item .select:not(.sel-fill) { width: 160px; max-width: none; }
.filter-grid .btn { flex: 0 0 auto; }
.filter-grid .btn[data-act="edit"][data-form="customer"] { margin-left: auto; }

/* ===== 输入 + 下拉并存（表单内行业 / 来源） ===== */
.sel-merge { display: flex; gap: 8px; align-items: center; }
.sel-merge .input { flex: 1; min-width: 0; }
.sel-merge .sel-fill { width: 118px; flex: none; }

/* ===== 标签维护 ===== */
.tag-title { font-size: 14.5px; font-weight: 600; color: var(--text); margin: 0 0 12px; }
.tag-add { display: flex; gap: 8px; margin-bottom: 14px; }
.tag-add .input { flex: 1; min-width: 0; }
.tag-list { display: flex; flex-wrap: wrap; gap: 8px; }
.tag-chip { display: inline-flex; align-items: center; gap: 6px; background: var(--surface-2); border: 1px solid var(--border); border-radius: 999px; padding: 5px 10px 5px 12px; font-size: 13px; color: var(--text); }
.tag-color-dot { width: 16px; height: 16px; border-radius: 50%; border: 2px solid rgba(0,0,0,0.12); padding: 0; cursor: pointer; flex: none; box-shadow: inset 0 0 0 1px rgba(255,255,255,0.35); }
.tag-color-grid { display: flex; flex-wrap: wrap; gap: 12px; padding: 6px 0 4px; }
.tag-color-cell { width: 38px; height: 38px; border-radius: 50%; border: 3px solid transparent; padding: 0; cursor: pointer; box-shadow: 0 0 0 1px rgba(0,0,0,0.08); }
.tag-color-cell.active { border-color: #fff; box-shadow: 0 0 0 2px var(--text), 0 0 0 4px rgba(0,0,0,0.06); }
.tag-del { width: 18px; height: 18px; border: none; border-radius: 50%; background: var(--surface-3); color: var(--text-2); font-size: 13px; line-height: 1; cursor: pointer; display: inline-flex; align-items: center; justify-content: center; }
.tag-del:hover { background: var(--danger); color: #fff; }
.tag-empty { font-size: 13px; color: var(--text-3); padding: 6px 0; }
.tag-check { display: inline-flex; align-items: center; gap: 6px; margin: 0 4px 8px 0; cursor: pointer; }
.tag-check input { position: absolute; opacity: 0; pointer-events: none; }
.tag-check .tag-chip { transition: border-color .15s, background .15s, color .15s; }
.tag-check input:checked + .tag-chip { background: var(--primary); border-color: var(--primary); color: #fff; }
.tag-check input:focus-visible + .tag-chip { outline: 2px solid var(--primary); outline-offset: 2px; }

/* ===== 客户列表分页 ===== */
.pager { display: flex; align-items: center; justify-content: flex-end; gap: 10px; flex-wrap: wrap; margin-top: 14px; }
.pager-btns { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.pager-btn { min-width: 34px; height: 32px; padding: 0 10px; border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--surface); color: var(--text-2); font-size: 13px; cursor: pointer; transition: border-color .15s, color .15s, background .15s; }
.pager-btn:hover:not(:disabled):not(.active) { border-color: var(--primary); color: var(--primary); }
.pager-btn.active { background: var(--primary); border-color: var(--primary); color: #fff; font-weight: 600; }
.pager-btn:disabled { opacity: .45; cursor: not-allowed; }
.pager-size { display: flex; align-items: center; gap: 6px; font-size: 13px; color: var(--text-2); white-space: nowrap; }
.pager-size .select { height: 32px; padding: 0 26px 0 10px; }
@media (max-width: 1023.98px) {
  .filter-bar { flex-wrap: wrap; }
  .filter-grid { width: 100%; }
}
@media (max-width: 640px) {
  .seg { flex-wrap: wrap; row-gap: 4px; max-width: 100%; }
  .filter-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .filter-item { flex-wrap: nowrap; }
  .filter-item .input { flex: 1; width: auto; max-width: none; }
  .filter-item .select:not(.sel-fill) { width: auto; max-width: 220px; }
  .filter-item .sel-fill { width: 118px; flex: none; }
  .filter-item:nth-child(3), .filter-item:nth-child(4) { grid-column: 1 / -1; }
  .filter-grid .btn { grid-column: 1 / -1; }
}

/* ===== ¼ÇÕËҳ ===== */
.ledger-tabs { max-width: 340px; }
.ledger-stats { grid-template-columns: repeat(3, 1fr); }
.ledger-stats .stat-value.expense { color: var(--danger); }
.ledger-stats .stat-value.income { color: var(--success); }
.ledger-day { border: 1px solid var(--border); border-radius: 10px; background: var(--surface); margin-bottom: 10px; overflow: hidden; }
.ledger-day-head { display: flex; align-items: center; justify-content: space-between; padding: 9px 14px; font-size: 13px; font-weight: 600; color: var(--text-2); background: var(--surface-2); border-bottom: 1px solid var(--border); }
.ledger-day-sum { font-family: var(--mono); font-variant-numeric: tabular-nums; font-size: 12.5px; }
.ledger-day-sum.income { color: var(--success); }
.ledger-day-sum.expense { color: var(--danger); }
.ledger-item { display: flex; align-items: center; gap: 10px; padding: 11px 14px; cursor: pointer; border-bottom: 1px dashed var(--border); }
.ledger-item:last-child { border-bottom: none; }
.ledger-item:hover { background: var(--surface-2); }
.ledger-chip { flex: none; display: inline-block; padding: 2px 9px; border-radius: 6px; font-size: 12px; font-weight: 600; background: var(--primary-soft); color: var(--primary-strong); }
.ledger-note { flex: 1; min-width: 0; font-size: 13px; color: var(--text-2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ledger-amount { flex: none; font-family: var(--mono); font-variant-numeric: tabular-nums; font-weight: 600; font-size: 13.5px; }
.ledger-amount.expense { color: var(--danger); }
.ledger-amount.income { color: var(--success); }
.ledger-kind { max-width: 240px; }
@media (max-width: 640px) {
  .ledger-stats { grid-template-columns: 1fr; }
}

/* ===== 项目成本表单行（v24） ===== */
.cost-line { display: flex; gap: 8px; align-items: center; margin-bottom: 8px; }
.cost-line .select { flex: none; }
.cost-line .input { flex: 1; min-width: 0; }
