:root {
  --bg: #f0f3f8;
  --card: #ffffff;
  --line: #e5e9f2;
  --text: #1f2733;
  --muted: #6b7686;
  --primary: #2f6bff;
  --primary-dark: #1f55d8;
  --danger: #e5484d;
  --ok: #18a058;
  --warn: #d97706;
  --sidebar: #17294d;
  --sidebar-text: #c6d2ea;
  --sidebar-active: #ffffff;
  --radius: 10px;
  --shadow: 0 1px 3px rgba(16,24,40,.08), 0 1px 2px rgba(16,24,40,.04);
}
* { box-sizing: border-box; }
body { margin: 0; font-family: "Microsoft YaHei", "PingFang SC", system-ui, sans-serif; background: var(--bg); color: var(--text); font-size: 14px; }
.hidden { display: none !important; }
code { background: #eef1f7; padding: 1px 5px; border-radius: 4px; }
.small { font-size: 12px; }

/* auth */
.auth-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; background: linear-gradient(135deg,#2f6bff 0%,#1f55d8 60%,#123e9e 100%); }
.auth-card { width: 380px; background: var(--card); border-radius: 14px; padding: 28px; box-shadow: 0 12px 40px rgba(0,0,0,.25); }
.auth-card h1 { margin: 0 0 2px; font-size: 24px; text-align: center; }
.auth-sub { margin: 0 0 18px; text-align: center; color: var(--muted); font-size: 13px; }
.tabs { display: flex; gap: 8px; margin-bottom: 16px; background: var(--bg); border-radius: 8px; padding: 4px; }
.tab-btn { flex: 1; border: 0; background: transparent; padding: 8px; border-radius: 6px; cursor: pointer; color: var(--muted); font-size: 14px; }
.tab-btn.active { background: var(--card); color: var(--primary); font-weight: 600; box-shadow: var(--shadow); }
.auth-form { display: flex; flex-direction: column; gap: 10px; }

/* buttons/inputs */
.btn { border: 1px solid var(--line); background: var(--card); color: var(--text); border-radius: 8px; padding: 7px 13px; cursor: pointer; font-size: 14px; }
.btn:hover { border-color: #b9c6dc; }
.btn.primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn.primary:hover { background: var(--primary-dark); }
.btn.ghost { background: transparent; }
.btn.danger { color: var(--danger); border-color: #f3c1c3; }
.btn.sm { padding: 4px 9px; font-size: 13px; }
.btn.block { width: 100%; padding: 10px; font-size: 15px; }
input, select, textarea { border: 1px solid var(--line); border-radius: 8px; padding: 7px 10px; font-size: 14px; font-family: inherit; background: #fff; color: var(--text); }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--primary); }
textarea { resize: vertical; }
label.chk { display: inline-flex; align-items: center; gap: 6px; color: var(--text); }
label.chk input { width: auto; }

/* topbar */
.topbar { display: flex; align-items: center; gap: 18px; background: var(--card); padding: 0 18px; height: 54px; box-shadow: var(--shadow); position: sticky; top: 0; z-index: 20; }
.brand { font-size: 17px; font-weight: 700; color: var(--primary); white-space: nowrap; }
.ver-badge { font-size: 11px; font-weight: 400; color: #fff; background: var(--primary); padding: 1px 7px; border-radius: 20px; vertical-align: 2px; }
.top-company { flex: 1; color: var(--muted); font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.user-box { display: flex; align-items: center; gap: 10px; color: var(--muted); white-space: nowrap; }

/* shell layout */
.shell { display: flex; min-height: calc(100vh - 54px); }
.sidebar { width: 212px; flex: none; background: var(--sidebar); padding: 12px 10px; color: var(--sidebar-text); }
.menu-group { font-size: 12px; color: #7f92b8; padding: 12px 10px 6px; letter-spacing: 1px; }
.menu-item { display: flex; align-items: center; justify-content: space-between; gap: 6px; padding: 9px 12px; border-radius: 8px; color: var(--sidebar-text); text-decoration: none; cursor: pointer; margin-bottom: 2px; font-size: 14px; }
.menu-item:hover { background: rgba(255,255,255,.08); color: #fff; }
.menu-item.active { background: var(--primary); color: var(--sidebar-active); font-weight: 600; }
.menu-item .cnt { font-size: 12px; opacity: .8; }
.main { flex: 1; overflow: auto; padding: 16px; }

/* cards */
.card { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: 14px 16px; margin-bottom: 12px; }
.card h2, .card h3 { margin: 0 0 6px; font-size: 16px; }
.card.bar { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; }
.card.bar h2 { margin: 0; }
.filter-bar { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.filter-bar input, .filter-bar select { width: auto; }
.filter-bar .flt-sel { display: inline-flex; align-items: center; gap: 2px; border: 1px solid var(--line); border-radius: 6px; padding-left: 8px; background: #fff; }
.filter-bar .flt-sel .flt-tag { font-size: 12px; color: var(--muted); white-space: nowrap; }
.filter-bar .flt-sel select { border: 0; background: transparent; padding: 4px 6px 4px 2px; }
#f-q { width: 190px; }
#f-product { width: 130px; }
#f-from, #f-to { width: 138px; }
.spacer { flex: 1; }
.imp-row > * { flex: 0 0 auto; }
.card.batch-bar { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.batch-bar select { width: auto; }
.batch-bar .btn:disabled { opacity: .45; cursor: not-allowed; }
.ck-col { width: 36px; text-align: center; }
.ck-col input, .ck-cell input { width: auto; margin: 0; vertical-align: middle; }
.ck-cell { text-align: center; white-space: nowrap; }

/* table */
.grid { width: 100%; border-collapse: collapse; }
.grid th { text-align: left; color: var(--muted); font-weight: 600; padding: 8px; border-bottom: 1px solid var(--line); white-space: nowrap; font-size: 13px; }
.grid td { padding: 8px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.grid tr:hover td { background: #f8faff; }
.grid a.name { color: var(--primary); text-decoration: none; cursor: pointer; font-weight: 500; }
.grid a.name:hover { text-decoration: underline; }
.muted { color: var(--muted); }
.danger-text { color: var(--danger); }
.ok-text { color: var(--ok); }
.link-btn { color: var(--primary); background: none; border: 0; cursor: pointer; font-size: 13px; padding: 2px 6px; text-decoration: none; }
.link-btn:hover { text-decoration: underline; }

/* pager */
.pager { display: flex; align-items: center; gap: 10px; padding-top: 12px; }
#page-info { flex: 1; }

/* modal */
.modal { position: fixed; inset: 0; background: rgba(15,23,42,.45); display: flex; align-items: center; justify-content: center; z-index: 100; padding: 16px; }
.modal-box { background: var(--card); border-radius: 12px; width: 470px; max-width: 100%; max-height: 90vh; display: flex; flex-direction: column; box-shadow: 0 20px 60px rgba(0,0,0,.3); }
.modal-box.wide { width: 700px; }
.modal-head { display: flex; align-items: center; justify-content: space-between; padding: 14px 18px; border-bottom: 1px solid var(--line); flex: none; }
.modal-head h3 { margin: 0; font-size: 16px; }
.modal-close { border: 0; background: none; font-size: 22px; cursor: pointer; color: var(--muted); line-height: 1; }
.modal-body { padding: 16px 18px; display: flex; flex-direction: column; gap: 10px; overflow-y: auto; }
.modal-foot { display: flex; justify-content: flex-end; gap: 8px; padding: 12px 18px; border-top: 1px solid var(--line); flex: none; }

/* meta grid */
.meta-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 6px 16px; background: var(--bg); border-radius: 10px; padding: 12px 14px; }
.meta-item .k { color: var(--muted); font-size: 12px; }
.meta-item .v { margin-top: 2px; word-break: break-all; }
.sub-title { font-weight: 600; margin-top: 6px; }

/* follow list */
.follow-list { max-height: 300px; overflow-y: auto; display: flex; flex-direction: column; gap: 8px; }
.follow-item { background: var(--bg); border-radius: 8px; padding: 8px 10px; font-size: 13px; border-left: 3px solid var(--primary); }
.follow-item .who { color: var(--muted); font-size: 12px; margin-bottom: 2px; display: flex; justify-content: space-between; }
.follow-item .next { color: var(--warn); font-size: 12px; margin-top: 3px; }
.follow-form { border-top: 1px dashed var(--line); padding-top: 10px; display: flex; flex-direction: column; gap: 8px; }
.form-row { display: flex; gap: 8px; flex-wrap: wrap; }
.form-row > * { flex: 1; min-width: 120px; }
.form-foot { display: flex; justify-content: flex-end; gap: 8px; }

/* toast */
.toast { position: fixed; top: 64px; left: 50%; transform: translateX(-50%); background: #1f2733; color: #fff; padding: 10px 18px; border-radius: 8px; z-index: 200; box-shadow: 0 6px 20px rgba(0,0,0,.3); max-width: 80vw; }
.toast.ok { background: var(--ok); }
.toast.err { background: var(--danger); }

#import-result { margin-top: 10px; }
#import-progress { margin-top: 8px; }
/* 修改撤回 */
.undo-ready { display: inline-block; font-size: 12px; color: var(--primary); background: #eef2fb; border-radius: 20px; padding: 0 8px; }
/* ===== 手机 / 窄屏自适应 ===== */
@media (max-width: 860px) {
  .topbar { gap: 10px; padding: 0 10px; height: 50px; }
  .brand { font-size: 15px; }
  .ver-badge { display: none; }
  .top-company { font-size: 12px; }
  .user-box { gap: 6px; font-size: 13px; }
  .shell { display: block; min-height: 0; }
  .sidebar { width: 100%; height: auto;
    display: flex; flex-wrap: wrap; gap: 6px; padding: 7px 8px; }
  .sidebar .menu-group { display: none; }
  .sidebar .menu-item { display: flex; align-items: center; justify-content: flex-start;
    flex: 0 1 auto; margin: 0; padding: 7px 11px; font-size: 13px; }
  .sidebar .menu-item .cnt { font-size: 11px; margin-left: 4px; }
  .main { padding: 10px; overflow: visible; }
  .card { padding: 12px; }
  .card.bar { align-items: center; }
  .filter-bar { align-items: stretch; }
  .filter-bar input, .filter-bar select { flex: 1 1 44%; min-width: 0; }
  #f-q { width: 100%; flex-basis: 100%; }
  #f-from, #f-to { flex: 1 1 44%; }
  .filter-bar .flt-sel { flex: 1 1 44%; min-width: 0; }
  .filter-bar .flt-sel select { flex: 1 1 auto; min-width: 0; }
  .batch-bar select { flex: 1 1 130px; min-width: 0; }
  /* 客户列表改成卡片 */
  #customers-view .grid thead { display: none; }
  #customers-view .grid tbody { display: flex; flex-direction: column; gap: 10px; }
  #customers-view .grid tr { display: block; width: 100%; position: relative; margin: 0;
    background: var(--card); border: 1px solid var(--line); border-radius: 12px;
    padding: 10px 12px 6px; box-shadow: var(--shadow); }
  #customers-view .grid td { display: flex; align-items: flex-start; justify-content: space-between;
    gap: 8px; padding: 4px 0; border-bottom: 1px dashed var(--line); font-size: 13px; }
  #customers-view .grid td::before { content: attr(data-label); flex: none; color: var(--muted); font-size: 12px; }
  #customers-view .grid td.cname { display: block; border-bottom: 1px solid var(--line);
    font-size: 15px; font-weight: 600; padding: 2px 26px 8px 0; }
  #customers-view .grid td.cname::before { content: none; }
  #customers-view .grid td.ck-cell { position: absolute; top: 10px; right: 10px; border: 0; padding: 0; }
  #customers-view .grid td.ck-cell::before { content: none; }
  #customers-view .grid td.ck-cell input { width: 18px; height: 18px; }
  #customers-view .grid td.ops { display: flex; flex-wrap: wrap; justify-content: flex-start;
    gap: 6px; border-bottom: 0; white-space: normal !important; padding-top: 8px; }
  #customers-view .grid td.ops::before { content: none; }
  #customers-view .grid td.ops .link-btn { padding: 6px 10px; border: 1px solid var(--line);
    border-radius: 8px; background: #f6f8fc; }
  #customers-view .grid td.empty-msg { display: block; text-align: center; border: 0; }
  #customers-view .grid td.empty-msg::before { content: none; }
  /* 管理页表格可横滑 */
  #users-view .card, #products-view .card { overflow-x: auto; }
  #users-view .grid, #products-view .grid { min-width: 640px; }
  #suppliers-view .card, #purchases-view .card { overflow-x: auto; }
  #suppliers-view .grid, #purchases-view .grid { min-width: 760px; }
  #undo-view .card { overflow-x: auto; }
  #undo-view .grid { min-width: 820px; }
  /* 弹窗 → 底部抽屉 */
  .modal { padding: 0; align-items: flex-end; }
  .modal-box { width: 100%; max-width: 100%; max-height: 92vh; border-radius: 14px 14px 0 0; }
  .modal-foot .btn { flex: 1; }
  .form-foot { flex-wrap: wrap; }
  .form-foot .btn { flex: 1; }
  .pager { flex-wrap: wrap; }
  #page-info { flex-basis: 100%; }
}
@media (max-width: 640px) {
  .top-company { display: none; }
  .filter-bar input, .filter-bar select { flex-basis: 100%; }
  #f-from, #f-to { flex-basis: calc(50% - 4px); }
  .batch-bar .btn { flex: 1 1 auto; min-width: 0; }
  .batch-bar .spacer { display: none; }
}



/* 新功能：成交 / 公共客户池 / 产品 */
.row-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.link-btn.primary-text { color: var(--primary); }
.ok-badge { display: inline-block; font-size: 11px; color: #fff; background: var(--ok); border-radius: 20px; padding: 0 6px; margin-left: 4px; vertical-align: 1px; }
.pending-badge { display: inline-block; font-size: 11px; color: #57606a; background: #e9edf2; border-radius: 20px; padding: 0 6px; margin-right: 6px; vertical-align: 1px; }
.part-badge { display: inline-block; font-size: 11px; color: #7a4d00; background: #ffe9b8; border-radius: 20px; padding: 0 6px; margin-right: 6px; vertical-align: 1px; }
.deal-list { display: flex; flex-direction: column; gap: 8px; max-height: 240px; overflow-y: auto; }
.deal-item { background: #f0faf3; border-radius: 8px; padding: 8px 10px; font-size: 13px; border-left: 3px solid var(--ok); }
.deal-item .who { color: var(--muted); font-size: 12px; margin-bottom: 2px; display: flex; justify-content: space-between; gap: 8px; flex-wrap: wrap; }
.card.bar .muted { font-size: 12px; margin-right: auto; }
#suppliers-view .card.bar, #purchases-view .card.bar { flex-wrap: wrap; }


/* 忘记密码 / 重置 */
.forgot-row { text-align: center; margin-top: 2px; }
.forgot-row a, .forgot-panel a { color: var(--primary); cursor: pointer; font-size: 13px; text-decoration: none; }
.forgot-panel { display: flex; flex-direction: column; gap: 10px; }
.forgot-result { font-size: 13px; line-height: 1.7; min-height: 18px; }
.ok-box { background: #f0faf3; border: 1px solid #bfe6cf; border-radius: 8px; padding: 10px; }
.err-text { color: var(--danger); }
#resetpw-name { color: var(--primary); }

/* 领取限制设置 */
.form-row .set-field { display: flex; flex-direction: column; gap: 4px; font-size: 13px; color: var(--muted); }
.form-row .set-field input { font-size: 15px; }

/* ===== 大类/成交补充/物流 ===== */
.cat-chips { display: flex; gap: 6px; flex-wrap: wrap; padding: 2px 0 10px; }
.chip { border: 1px solid var(--line); background: #fff; color: var(--muted); border-radius: 999px; padding: 4px 14px; font-size: 13px; cursor: pointer; }
.chip.active { background: var(--primary); border-color: var(--primary); color: #fff; }
.spec-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 8px; }
.spec-item { display: flex; flex-direction: column; gap: 4px; font-size: 12px; color: var(--muted); }
.spec-item input, .spec-item select { width: 100%; }
.spec-pills { display: flex; flex-wrap: wrap; gap: 4px; padding-top: 6px; }
.spec-pill { font-size: 12px; background: #eef2fb; color: #2f3b52; border-radius: 6px; padding: 2px 8px; text-decoration: none; }
.small-title { font-size: 13px; margin: 6px 0 4px; }
.deal-item .ok-badge { display: inline-block; margin-right: 6px; }
.deal-item .deal-line { padding-top: 5px; font-size: 13px; color: var(--text); white-space: pre-wrap; word-break: break-word; line-height: 1.6; }
.deal-item .deal-line b { color: var(--muted); font-weight: 600; margin-right: 2px; }
#deal-address, #deal-note { min-height: 92px; line-height: 1.6; }
.contract-row { align-items: center; flex-wrap: wrap; }

/* ===== 收款管理 / 拨号 / 收款比例图 ===== */
a.tel { color: var(--primary); text-decoration: none; font-weight: 600; }
a.tel:hover { text-decoration: underline; }
.pay-summary { display: flex; align-items: center; gap: 22px; flex-wrap: wrap; padding: 6px 2px; }
.pay-ring-wrap { position: relative; width: 120px; height: 120px; flex: none; }
.pay-ring { width: 120px; height: 120px; transform: rotate(-90deg); }
.pay-ring circle { fill: none; stroke-width: 12; }
.ring-bg { stroke: #e8edf5; }
.ring-fg { stroke: var(--ok); stroke-linecap: round; transition: stroke-dasharray .4s ease; }
.ring-center { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; font-size: 20px; font-weight: 700; color: var(--primary); }
.pay-nums { display: flex; gap: 26px; flex-wrap: wrap; }
.pn-main { display: flex; flex-direction: column; align-items: flex-start; }
.pn-main b { font-size: 20px; color: var(--primary); }
.pn-main .pn-lbl { color: var(--muted); font-size: 12px; }
.pay-mini { height: 6px; border-radius: 4px; background: #e8edf5; overflow: hidden; margin-top: 3px; }
.pay-mini i { display: block; height: 100%; background: var(--ok); border-radius: 4px; }
.deal-item .payline { margin-top: 6px; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; font-size: 13px; }
.pay-state { display: inline-block; font-size: 12px; padding: 1px 8px; border-radius: 20px; white-space: nowrap; }
.pay-state.pending { background: #fff3d6; color: #a16207; }
.pay-state.approved { background: #e1f5ea; color: #0d7a43; }
.pay-state.rejected { background: #fde8e8; color: #c0373c; }
#payments-view .grid { min-width: 900px; }
#accounts-card .grid { min-width: 460px; }
.shot-link { color: var(--primary); text-decoration: none; font-size: 12px; }
.shot-link:hover { text-decoration: underline; }
@media (max-width: 860px) {
  #payments-view .card { padding: 10px; }
  #payments-view .card.bar { flex-wrap: wrap; }
  #payments-view .card.bar .muted { flex-basis: 100%; }
  .pay-summary { gap: 14px; }
}
select.role-sel { padding: 2px 4px; font-size: 12px; border-radius: 6px; }

/* 修复：成交记录 / 跟进记录 容器被外层 flex 压缩成 0 高度 */
.deal-list, .follow-list { flex: none; }
@media (max-width: 860px) {
  .deal-list, .follow-list { max-height: none; overflow: visible; }
  .modal-body { padding: 14px 12px; }
  .meta-item .k { font-size: 13px; }
  .meta-item .v { font-size: 14px; }
  .deal-item, .follow-item { font-size: 14px; padding: 10px 12px; border-radius: 10px; }
  .deal-item .who, .follow-item .who { font-size: 13px; }
  .deal-item .deal-line { font-size: 14px; }
  .spec-pill { font-size: 13px; padding: 3px 9px; }
  .follow-item .next { font-size: 13px; }
  .follow-list .follow-item .who { font-size: 13px; }
}

/* ---- 免费试用 / VIP ---- */
.trial-note { margin: 10px 0 0; font-size: 13px; color: #1e40af; background: #eff6ff; border: 1px dashed #93c5fd; border-radius: 8px; padding: 8px 10px; line-height: 1.6; }
.trial-banner { background: #fffbeb; color: #92400e; border-bottom: 1px solid #fde68a; font-size: 13px; padding: 6px 14px; text-align: center; line-height: 1.6; }
.expired-view { position: fixed; inset: 0; background: rgba(15,23,42,.55); display: flex; align-items: center; justify-content: center; z-index: 300; padding: 16px; }
.expired-card { width: 380px; max-width: 100%; background: #fff; border-radius: 14px; padding: 26px 22px; box-shadow: 0 12px 40px rgba(0,0,0,.3); text-align: center; }
.expired-card h3 { margin: 0 0 12px; font-size: 20px; }
.expired-card p { margin: 6px 0; font-size: 14px; line-height: 1.8; color: #334155; }
.expired-card .tel { font-size: 18px; font-weight: 700; color: #2563eb; text-decoration: none; }
.expired-view .btn { margin-top: 14px; }
@media (max-width: 860px) {
  .expired-card { padding: 22px 16px; }
}

/* ---- 收款账户：二维码 / 对公信息 ---- */
.pay-way-acts { display:inline-flex; gap:6px; flex-wrap:wrap; }
.ac-qr-prev { margin:2px 0 8px; }
.ac-qr-prev img { max-width:150px; max-height:150px; border:1px solid #e5e7eb; border-radius:8px; display:block; background:#fff; }
.pay-qr-box { display:flex; align-items:flex-start; gap:10px; padding:8px 10px; background:#f8fafc; border:1px solid #eef1f6; border-radius:8px; margin:2px 0 8px; }
.pay-qr-box img { width:64px; height:64px; object-fit:contain; border:1px solid #e5e7eb; border-radius:6px; cursor:pointer; background:#fff; flex:none; }
.pay-qr-box .btn { margin-top:4px; }

/* ---- 表单字段常驻小标题：输入框填了内容后依然知道该填什么 ---- */
.fld { display: flex; flex-direction: column; gap: 4px; font-size: 12px; color: var(--muted); min-width: 0; }
.fld > .fld-cap { line-height: 1.35; }
.fld > input, .fld > select, .fld > textarea { width: 100%; }

/* ---- 客户详情：一键改状态 ---- */
.state-row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-bottom: 2px; }
.state-row-cap { font-size: 12px; color: var(--muted); }
.state-chips { display: inline-flex; gap: 6px; flex-wrap: wrap; }
.follow-item.is-system { opacity: .72; }

/* ---- 收款截图：多张上传 + 查看 ---- */
.file-list { display: flex; flex-direction: column; gap: 4px; }
.file-list:empty { display: none; }
.file-list .file-item { display: flex; align-items: center; gap: 8px; padding: 5px 8px; background: #f8fafc; border: 1px solid #eef1f6; border-radius: 6px; font-size: 12px; }
.file-list .file-item .fname { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.shot-gallery { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; }
.shot-gallery .shot-item { display: flex; flex-direction: column; align-items: center; gap: 6px; padding: 8px; border: 1px solid #eef1f6; border-radius: 8px; background: #f8fafc; text-decoration: none; color: inherit; font-size: 12px; }
.shot-gallery .shot-item img { width: 100%; height: 120px; object-fit: contain; background: #fff; border-radius: 6px; }
.shot-gallery .shot-item > span:last-child { max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.shot-gallery .shot-item .pdf-ico { display: flex; align-items: center; justify-content: center; width: 100%; height: 120px; background: #fff; border-radius: 6px; color: #b91c1c; font-weight: 700; }
