/* 客户沟通台 · 设计系统
   暖纸底 + 墨色字 + 靛青主色。无外部依赖。 */
:root {
  --bg: #f6f4ef;
  --paper: #fffdf9;
  --paper-2: #fbf8f2;
  --ink: #1d1b18;
  --ink-2: #4a463f;
  --ink-3: #8a8279;
  --line: #e6e0d5;
  --line-2: #d8d0c2;
  --brand: #2f5fa8;
  --brand-ink: #234a86;
  --brand-soft: #e8eefa;
  --teal: #15705c;
  --teal-soft: #e2f2ee;
  --amber: #9a6412;
  --amber-soft: #fbf0dd;
  --red: #b43a2e;
  --red-soft: #fbe8e5;
  --violet: #5b4fc4;
  --violet-soft: #ecebfa;
  --radius: 14px;
  --radius-sm: 9px;
  --shadow: 0 1px 2px rgba(29,27,24,.04), 0 8px 24px rgba(29,27,24,.06);
  --shadow-lg: 0 24px 64px rgba(29,27,24,.18);
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  font-family: var(--font); background: var(--bg); color: var(--ink);
  font-size: 14px; line-height: 1.65; -webkit-font-smoothing: antialiased;
}
.hidden { display: none !important; }
a { color: var(--brand); text-decoration: none; }
h1, h2, h3, h4 { margin: 0; font-weight: 650; letter-spacing: -.01em; }
button, input, select, textarea { font-family: inherit; font-size: inherit; color: inherit; }

/* ---------------- 登录 ---------------- */
.login-screen {
  min-height: 100%; display: grid; place-items: center; padding: 24px;
  background:
    radial-gradient(900px 420px at 12% -8%, var(--brand-soft), transparent 62%),
    radial-gradient(720px 380px at 96% 108%, var(--teal-soft), transparent 60%),
    var(--bg);
}
.login-card {
  width: min(420px, 100%); background: var(--paper); border: 1px solid var(--line);
  border-radius: 18px; padding: 34px 30px 28px; box-shadow: var(--shadow);
}
.login-brand { display: flex; align-items: center; gap: 11px; margin-bottom: 6px; }
.brand-mark {
  width: 38px; height: 38px; border-radius: 11px; display: grid; place-items: center;
  background: linear-gradient(140deg, var(--brand), var(--violet)); color: #fff;
  font-weight: 700; font-size: 17px; letter-spacing: .02em;
}
.login-card h1 { font-size: 20px; }
.login-sub { color: var(--ink-3); font-size: 13px; margin: 2px 0 22px; }
.login-card .field { margin-bottom: 13px; }
.login-foot { margin-top: 16px; font-size: 12px; color: var(--ink-3); }

/* ---------------- 外框 ---------------- */
.app { display: grid; grid-template-columns: 236px 1fr; height: 100%; }
.sidebar {
  background: var(--paper-2); border-right: 1px solid var(--line);
  display: flex; flex-direction: column; padding: 18px 12px; overflow-y: auto;
}
.side-brand { display: flex; align-items: center; gap: 10px; padding: 2px 8px 18px; }
.side-brand .brand-mark { width: 32px; height: 32px; font-size: 15px; border-radius: 9px; }
.side-brand-text b { display: block; font-size: 14.5px; }
.side-brand-text span { font-size: 11px; color: var(--ink-3); }
.nav-group { margin-bottom: 14px; }
.nav-label {
  font-size: 11px; letter-spacing: .09em; text-transform: uppercase;
  color: var(--ink-3); padding: 0 10px 6px;
}
.nav-item {
  display: flex; align-items: center; gap: 9px; padding: 8px 11px; border-radius: 9px;
  color: var(--ink-2); cursor: pointer; font-size: 13.5px;
  border: 1px solid transparent; transition: background .14s, color .14s;
}
.nav-item:hover { background: #efeade; color: var(--ink); }
.nav-item.active { background: var(--paper); color: var(--brand-ink); border-color: var(--line); font-weight: 600; }
.nav-item .ico { width: 17px; text-align: center; opacity: .85; font-size: 14px; }
.nav-item .count {
  margin-left: auto; min-width: 20px; height: 18px; padding: 0 6px; border-radius: 9px;
  background: var(--brand-soft); color: var(--brand-ink); font-size: 11px; font-weight: 600;
  display: grid; place-items: center;
}
.nav-item .count.alert { background: var(--red-soft); color: var(--red); }
.side-foot { margin-top: auto; padding: 10px 8px 0; font-size: 11.5px; color: var(--ink-3); }

.main { display: flex; flex-direction: column; min-width: 0; height: 100%; }
.topbar {
  height: 58px; flex: 0 0 58px; display: flex; align-items: center; gap: 14px;
  padding: 0 22px; background: rgba(255,253,249,.86); backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 20;
}
.topbar h2 { font-size: 16px; }
.topbar-sub { font-size: 12.5px; color: var(--ink-3); }
.topbar-actions { margin-left: auto; display: flex; align-items: center; gap: 9px; }
.user-chip {
  display: flex; align-items: center; gap: 8px; padding: 5px 10px 5px 6px;
  border: 1px solid var(--line); border-radius: 999px; background: var(--paper); font-size: 12.5px;
}
.avatar {
  width: 24px; height: 24px; border-radius: 50%; display: grid; place-items: center;
  background: var(--brand-soft); color: var(--brand-ink); font-size: 11px; font-weight: 700;
}
.view { flex: 1; overflow-y: auto; padding: 22px 26px 56px; }
.page-head { display: flex; align-items: flex-end; gap: 14px; margin-bottom: 18px; flex-wrap: wrap; }
.page-head h1 { font-size: 21px; }
.page-head p { margin: 3px 0 0; color: var(--ink-3); font-size: 13px; }
.page-head .spacer { flex: 1; }

/* ---------------- 组件 ---------------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  height: 34px; padding: 0 14px; border-radius: 9px; border: 1px solid var(--line-2);
  background: var(--paper); color: var(--ink); cursor: pointer; font-size: 13px;
  transition: background .14s, border-color .14s, transform .06s;
  white-space: nowrap;
}
.btn:hover { background: #f4f0e8; }
.btn:active { transform: translateY(1px); }
.btn.primary { background: var(--brand); border-color: var(--brand); color: #fff; font-weight: 600; }
.btn.primary:hover { background: var(--brand-ink); }
.btn.ghost { background: transparent; border-color: transparent; color: var(--ink-2); }
.btn.ghost:hover { background: #efeade; }
.btn.danger { color: var(--red); border-color: var(--red-soft); background: var(--red-soft); }
.btn.sm { height: 28px; padding: 0 10px; font-size: 12.5px; border-radius: 7px; }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn .spin {
  width: 13px; height: 13px; border: 2px solid currentColor; border-right-color: transparent;
  border-radius: 50%; animation: spin .7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.card {
  background: var(--paper); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 18px; box-shadow: var(--shadow);
}
.card + .card { margin-top: 16px; }
.card-head { display: flex; align-items: center; gap: 10px; margin-bottom: 14px; }
.card-head h3 { font-size: 15px; }
.card-head .spacer { flex: 1; }
.card-head .hint { font-size: 12px; color: var(--ink-3); }

.grid { display: grid; gap: 16px; }
.grid.cols-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid.cols-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid.cols-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
@media (max-width: 1180px) { .grid.cols-4 { grid-template-columns: repeat(2, minmax(0,1fr)); } }
@media (max-width: 900px) {
  .app { grid-template-columns: 1fr; }
  .sidebar { position: fixed; inset: 0 auto 0 0; width: 236px; z-index: 60; transform: translateX(-100%); transition: transform .2s; }
  .sidebar.open { transform: none; }
  .grid.cols-2, .grid.cols-3 { grid-template-columns: 1fr; }
}

/* 统计卡片 */
.stat { background: var(--paper); border: 1px solid var(--line); border-radius: var(--radius); padding: 15px 17px; }
.stat .k { font-size: 12px; color: var(--ink-3); display: flex; align-items: center; gap: 6px; }
.stat .v { font-size: 27px; font-weight: 700; letter-spacing: -.02em; margin-top: 3px; line-height: 1.15; }
.stat .v small { font-size: 13px; font-weight: 500; color: var(--ink-3); margin-left: 5px; }
.stat.warn { border-color: #f0d9b4; background: linear-gradient(180deg, var(--amber-soft), var(--paper) 70%); }
.stat.warn .v { color: var(--amber); }
.stat.alert { border-color: #f2cbc4; background: linear-gradient(180deg, var(--red-soft), var(--paper) 70%); }
.stat.alert .v { color: var(--red); }

/* 表单 */
.field { display: flex; flex-direction: column; gap: 5px; }
.field > label { font-size: 12.5px; color: var(--ink-2); font-weight: 550; }
.field > label .req { color: var(--red); }
.input, .select, .textarea {
  width: 100%; background: var(--paper); border: 1px solid var(--line-2); border-radius: 9px;
  padding: 8px 11px; outline: none; transition: border-color .14s, box-shadow .14s;
}
.input:focus, .select:focus, .textarea:focus {
  border-color: var(--brand); box-shadow: 0 0 0 3px rgba(47,95,168,.12);
}
.textarea { min-height: 88px; resize: vertical; line-height: 1.6; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0,1fr)); gap: 13px; }
.form-grid .span-2 { grid-column: span 2; }
@media (max-width: 720px) { .form-grid { grid-template-columns: 1fr; } .form-grid .span-2 { grid-column: auto; } }
.hint-text { font-size: 12px; color: var(--ink-3); }

/* 标签 / 徽章 */
.tag {
  display: inline-flex; align-items: center; height: 21px; padding: 0 8px; border-radius: 6px;
  background: #efeade; color: var(--ink-2); font-size: 11.5px; white-space: nowrap;
}
.badge {
  display: inline-flex; align-items: center; gap: 5px; height: 22px; padding: 0 9px;
  border-radius: 999px; font-size: 11.5px; font-weight: 600; white-space: nowrap;
}
.badge::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.badge.open { background: var(--brand-soft); color: var(--brand-ink); }
.badge.done { background: var(--teal-soft); color: var(--teal); }
.badge.overdue { background: var(--red-soft); color: var(--red); }
.badge.today { background: var(--amber-soft); color: var(--amber); }
.badge.high { background: var(--red-soft); color: var(--red); }
.badge.normal { background: #efeade; color: var(--ink-2); }
.badge.low { background: #eef0f2; color: var(--ink-3); }

/* 列表 */
.list { display: flex; flex-direction: column; }
.list-row {
  display: flex; align-items: flex-start; gap: 13px; padding: 13px 6px;
  border-bottom: 1px solid var(--line); cursor: default;
}
.list-row:last-child { border-bottom: none; }
.list-row.clickable { cursor: pointer; border-radius: 9px; padding-left: 9px; padding-right: 9px; }
.list-row.clickable:hover { background: var(--paper-2); }
.list-row .main-col { flex: 1; min-width: 0; }
.list-row .title { font-weight: 600; font-size: 13.5px; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.list-row .meta { font-size: 12px; color: var(--ink-3); margin-top: 2px; display: flex; gap: 10px; flex-wrap: wrap; }
.list-row .side { display: flex; align-items: center; gap: 7px; flex-shrink: 0; }

.empty {
  padding: 34px 16px; text-align: center; color: var(--ink-3); font-size: 13px;
  border: 1px dashed var(--line-2); border-radius: var(--radius); background: var(--paper-2);
}

/* 客户卡 */
.cust-card {
  background: var(--paper); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 15px 16px; cursor: pointer; transition: box-shadow .15s, transform .15s, border-color .15s;
  display: flex; flex-direction: column; gap: 9px;
}
.cust-card:hover { box-shadow: var(--shadow); border-color: var(--line-2); transform: translateY(-1px); }
.cust-card .row1 { display: flex; align-items: center; gap: 10px; }
.cust-avatar {
  width: 36px; height: 36px; border-radius: 10px; display: grid; place-items: center;
  font-weight: 700; font-size: 14px; color: #fff; flex-shrink: 0;
}
.cust-card .name { font-weight: 650; font-size: 14.5px; }
.cust-card .company { font-size: 12px; color: var(--ink-3); }
.cust-card .foot { display: flex; align-items: center; gap: 8px; font-size: 12px; color: var(--ink-3); flex-wrap: wrap; }
.cust-card .foot .dot { width: 3px; height: 3px; border-radius: 50%; background: currentColor; opacity: .5; }

/* 时间线 */
.timeline { position: relative; padding-left: 20px; }
.timeline::before {
  content: ""; position: absolute; left: 5px; top: 4px; bottom: 4px; width: 2px;
  background: linear-gradient(var(--line-2), transparent);
}
.tl-item { position: relative; padding-bottom: 16px; }
.tl-item:last-child { padding-bottom: 0; }
.tl-item::before {
  content: ""; position: absolute; left: -19px; top: 6px; width: 9px; height: 9px; border-radius: 50%;
  background: var(--paper); border: 2px solid var(--brand);
}
.tl-item .tl-head { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.tl-item .tl-date { font-size: 12px; color: var(--ink-3); font-variant-numeric: tabular-nums; }
.tl-item .tl-body { margin-top: 5px; font-size: 13px; white-space: pre-wrap; color: var(--ink-2); }

/* 截图预览 */
.shot-frame {
  border: 1px solid var(--line); border-radius: 10px; overflow: hidden; background: var(--paper-2);
  max-height: 240px; display: grid; place-items: center;
}
.shot-frame img { max-width: 100%; max-height: 240px; object-fit: contain; display: block; cursor: zoom-in; }
.dropzone {
  border: 2px dashed var(--line-2); border-radius: var(--radius); padding: 28px 18px;
  text-align: center; color: var(--ink-3); cursor: pointer; transition: border-color .15s, background .15s;
  background: var(--paper-2);
}
.dropzone:hover, .dropzone.drag { border-color: var(--brand); background: var(--brand-soft); color: var(--brand-ink); }
.dropzone .big { font-size: 26px; display: block; margin-bottom: 6px; }

/* 话术卡 */
.script-card {
  background: var(--paper); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 15px 16px; display: flex; flex-direction: column; gap: 9px;
}
.script-card .sc-head { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.script-card .sc-title { font-weight: 650; font-size: 14px; }
.script-card .sc-body {
  font-size: 13px; color: var(--ink-2); line-height: 1.7; white-space: pre-wrap;
  background: var(--paper-2); border-radius: 9px; padding: 11px 12px; border: 1px solid var(--line);
}
.script-card .sc-foot { display: flex; align-items: center; gap: 7px; flex-wrap: wrap; }

/* 模态框 */
.modal-mask {
  position: fixed; inset: 0; background: rgba(29,27,24,.42); backdrop-filter: blur(2px);
  display: grid; place-items: center; padding: 20px; z-index: 100; animation: fade .14s ease;
}
@keyframes fade { from { opacity: 0; } }
.modal {
  width: min(720px, 100%); max-height: 90vh; display: flex; flex-direction: column;
  background: var(--paper); border-radius: 16px; box-shadow: var(--shadow-lg);
  animation: pop .16s cubic-bezier(.2,.9,.3,1.2); overflow: hidden;
}
@keyframes pop { from { transform: translateY(10px) scale(.985); opacity: 0; } }
.modal.wide { width: min(940px, 100%); }
.modal.narrow { width: min(460px, 100%); }
.modal-head {
  display: flex; align-items: center; gap: 10px; padding: 16px 20px;
  border-bottom: 1px solid var(--line); flex-shrink: 0;
}
.modal-head h3 { font-size: 15.5px; }
.modal-head .spacer { flex: 1; }
.modal-body { padding: 18px 20px; overflow-y: auto; }
.modal-foot {
  display: flex; align-items: center; gap: 9px; padding: 14px 20px;
  border-top: 1px solid var(--line); background: var(--paper-2); flex-shrink: 0;
}
.modal-foot .spacer { flex: 1; }
.x-btn {
  width: 30px; height: 30px; border-radius: 8px; border: none; background: transparent;
  color: var(--ink-3); font-size: 18px; cursor: pointer; display: grid; place-items: center;
}
.x-btn:hover { background: #efeade; color: var(--ink); }

/* Toast */
.toast-root {
  position: fixed; top: 14px; left: 50%; transform: translateX(-50%);
  display: flex; flex-direction: column; gap: 8px; z-index: 200; pointer-events: none;
}
.toast {
  background: var(--ink); color: #fff; padding: 9px 15px; border-radius: 10px; font-size: 13px;
  box-shadow: var(--shadow); animation: drop .18s ease; max-width: 560px;
}
.toast.err { background: var(--red); }
.toast.ok { background: var(--teal); }
@keyframes drop { from { transform: translateY(-8px); opacity: 0; } }

/* 分段控件 */
.seg { display: inline-flex; background: #efeade; border-radius: 9px; padding: 3px; gap: 2px; }
.seg button {
  border: none; background: transparent; padding: 5px 13px; border-radius: 7px;
  font-size: 12.5px; color: var(--ink-2); cursor: pointer; transition: background .14s, color .14s;
}
.seg button.active { background: var(--paper); color: var(--ink); font-weight: 600; box-shadow: 0 1px 2px rgba(0,0,0,.06); }

/* 详情两栏 */
.detail-grid { display: grid; grid-template-columns: minmax(0,1.35fr) minmax(300px,1fr); gap: 16px; align-items: start; }
@media (max-width: 1000px) { .detail-grid { grid-template-columns: 1fr; } }

/* 检查清单 */
.check-list { display: flex; flex-direction: column; gap: 8px; }
.check-item {
  display: flex; gap: 10px; align-items: flex-start; padding: 10px 12px;
  border: 1px solid var(--line); border-radius: 9px; background: var(--paper-2);
}
.check-item input[type=checkbox] { margin-top: 3px; width: 15px; height: 15px; accent-color: var(--brand); cursor: pointer; }
.check-item .ci-body { flex: 1; min-width: 0; }
.check-item .ci-title { font-size: 13px; font-weight: 550; }
.check-item .ci-sub { font-size: 12px; color: var(--ink-3); margin-top: 1px; }

/* 键值 */
.kv { display: grid; grid-template-columns: 92px 1fr; gap: 7px 12px; font-size: 13px; }
.kv dt { color: var(--ink-3); font-size: 12.5px; }
.kv dd { margin: 0; color: var(--ink); }

/* 代码块 / 原文 */
.raw-box {
  font-family: var(--mono); font-size: 12.5px; line-height: 1.7; white-space: pre-wrap;
  background: #f4f1ea; border: 1px solid var(--line); border-radius: 9px; padding: 12px 13px;
  max-height: 220px; overflow-y: auto; color: var(--ink-2);
}

/* 弹层大图 */
.img-viewer {
  position: fixed; inset: 0; background: rgba(20,18,15,.9); z-index: 150;
  display: grid; place-items: center; padding: 28px; cursor: zoom-out;
}
.img-viewer img { max-width: 100%; max-height: 100%; border-radius: 6px; box-shadow: var(--shadow-lg); }

/* 表格 */
.table { width: 100%; border-collapse: collapse; font-size: 13px; }
.table th {
  text-align: left; font-weight: 600; color: var(--ink-3); font-size: 12px;
  padding: 9px 10px; border-bottom: 1px solid var(--line-2); white-space: nowrap;
}
.table td { padding: 10px; border-bottom: 1px solid var(--line); vertical-align: top; }
.table tr:last-child td { border-bottom: none; }
.table tr:hover td { background: var(--paper-2); }

.loading { padding: 40px; text-align: center; color: var(--ink-3); font-size: 13px; }
.loading::before {
  content: ""; display: inline-block; width: 14px; height: 14px; margin-right: 8px;
  border: 2px solid var(--ink-3); border-right-color: transparent; border-radius: 50%;
  animation: spin .7s linear infinite; vertical-align: -2px;
}
