/* ==========================================================
   创想客户档案与回访管理软件 v1.0
   基础设计系统：色彩、排版、按钮、表单、表格、弹窗
   ========================================================== */
:root {
  --ink: #12201C;
  --ink-2: #1B2C27;
  --ink-3: #263A34;
  --paper: #F4F0E6;
  --paper-2: #FAF7EF;
  --card: #FFFFFF;
  --card-soft: #FCFAF4;
  --line: #E3DBC9;
  --line-soft: #EFE9DA;
  --teal: #1D5B51;
  --teal-2: #2C7A6C;
  --teal-soft: #E7F0EC;
  --gold: #BE9553;
  --gold-2: #D9B87C;
  --gold-soft: #F4E9D4;
  --amber: #C98324;
  --danger: #B44531;
  --danger-soft: #F8E7E2;
  --blue: #35688E;
  --blue-soft: #E6EEF5;
  --muted: #83867C;
  --text: #27322D;
  --text-2: #55605A;
  --shadow-sm: 0 1px 2px rgba(26, 38, 32, .05), 0 4px 14px rgba(26, 38, 32, .05);
  --shadow-md: 0 10px 34px rgba(20, 32, 27, .10);
  --shadow-lg: 0 24px 70px rgba(14, 24, 20, .22);
  --r-sm: 8px;
  --r-md: 12px;
  --r-lg: 16px;
  --sidebar-w: 252px;
  --font-sans: "PingFang SC", "HarmonyOS Sans SC", "Microsoft YaHei", "Hiragino Sans GB", sans-serif;
  --font-serif: Georgia, "Times New Roman", "Songti SC", serif;
  --font-mono: "SFMono-Regular", Consolas, "Liberation Mono", monospace;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: var(--font-sans);
  font-size: 13px;
  color: var(--text);
  background: var(--paper);
  -webkit-font-smoothing: antialiased;
  line-height: 1.6;
}
a { color: inherit; text-decoration: none; }
button, input, select, textarea { font-family: inherit; font-size: inherit; color: inherit; }
button { cursor: pointer; border: none; background: none; }
ul, ol { margin: 0; padding: 0; list-style: none; }
h1, h2, h3, h4, h5 { margin: 0; font-weight: 600; letter-spacing: .01em; }
p { margin: 0; }
img, svg { display: block; }

::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(29, 91, 81, .18); border-radius: 8px; }
::-webkit-scrollbar-thumb:hover { background: rgba(29, 91, 81, .32); }

::selection { background: var(--gold-soft); color: var(--ink); }

/* ---------- 通用按键 ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  height: 34px; padding: 0 15px; border-radius: var(--r-sm);
  font-size: 13px; font-weight: 500; white-space: nowrap;
  border: 1px solid transparent; transition: all .18s ease;
  position: relative; overflow: hidden;
}
.btn i { font-size: 14px; }
.btn-primary {
  background: linear-gradient(135deg, #23685C, #164A41);
  color: #fff; border-color: #164A41;
  box-shadow: 0 6px 16px rgba(22, 74, 65, .22), inset 0 1px 0 rgba(255, 255, 255, .18);
}
.btn-primary:hover { transform: translateY(-1px); box-shadow: 0 10px 22px rgba(22, 74, 65, .3); }
.btn-gold {
  background: linear-gradient(135deg, #D3AC6C, #B98A45);
  color: #2A2113; border-color: #B98A45;
  box-shadow: 0 6px 16px rgba(185, 138, 69, .24), inset 0 1px 0 rgba(255, 255, 255, .35);
}
.btn-gold:hover { transform: translateY(-1px); }
.btn-ghost { background: #fff; border-color: var(--line); color: var(--text-2); }
.btn-ghost:hover { border-color: var(--teal-2); color: var(--teal); background: #fff; }
.btn-soft { background: var(--teal-soft); color: var(--teal); border-color: transparent; }
.btn-soft:hover { background: #DBEAE4; }
.btn-danger-soft { background: var(--danger-soft); color: var(--danger); }
.btn-danger-soft:hover { background: #F3D8D0; }
.btn-text { padding: 0 8px; height: 26px; color: var(--teal); font-size: 12px; }
.btn-text:hover { background: var(--teal-soft); }
.btn-sm { height: 28px; padding: 0 10px; font-size: 12px; border-radius: 7px; }
.btn-sm i { font-size: 12px; }
.btn-lg { height: 42px; padding: 0 22px; font-size: 14px; border-radius: 10px; }
.btn[disabled] { opacity: .5; pointer-events: none; }
.btn-block { width: 100%; }

.icon-btn {
  width: 34px; height: 34px; display: inline-flex; align-items: center; justify-content: center;
  border-radius: 9px; color: var(--text-2); border: 1px solid transparent; transition: .18s;
}
.icon-btn:hover { background: #fff; border-color: var(--line); color: var(--teal); }
.icon-btn i { font-size: 16px; }

/* ---------- 表单 ---------- */
.field-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px 18px; }
.field-grid.col-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.field.full { grid-column: 1 / -1; }
.field > label { font-size: 12px; color: var(--text-2); font-weight: 500; letter-spacing: .02em; }
.field > label .req { color: var(--danger); margin-left: 2px; }
.input, .select, .textarea {
  width: 100%; border: 1px solid var(--line); background: #FDFBF6;
  border-radius: var(--r-sm); padding: 0 12px; height: 36px;
  transition: .18s; color: var(--text); outline: none;
}
.textarea { height: auto; min-height: 84px; padding: 9px 12px; resize: vertical; line-height: 1.7; }
.input:focus, .select:focus, .textarea:focus {
  border-color: var(--teal-2); background: #fff; box-shadow: 0 0 0 3px rgba(44, 122, 108, .1);
}
.input::placeholder, .textarea::placeholder { color: #B2B3AA; }
.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 16 16'%3E%3Cpath fill='%237C8078' d='M8 11.5 2.5 6h11L8 11.5z'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 11px center; padding-right: 30px;
}
.input-sm { height: 32px; font-size: 12px; }
.field-hint { font-size: 11px; color: var(--muted); }
.checkline { display: flex; align-items: center; gap: 7px; font-size: 12px; color: var(--text-2); }
.checkline input { accent-color: var(--teal); width: 14px; height: 14px; }
.switch { position: relative; display: inline-block; width: 38px; height: 21px; flex: none; }
.switch input { opacity: 0; width: 0; height: 0; }
.switch span { position: absolute; inset: 0; background: #D8D3C6; border-radius: 22px; transition: .2s; }
.switch span:before { content: ""; position: absolute; width: 15px; height: 15px; left: 3px; top: 3px; background: #fff; border-radius: 50%; transition: .2s; box-shadow: 0 1px 3px rgba(0,0,0,.2); }
.switch input:checked + span { background: var(--teal); }
.switch input:checked + span:before { transform: translateX(17px); }

/* ---------- 标记 ---------- */
.static-value {
  min-height: 36px; display: flex; align-items: center; padding: 0 12px;
  background: #FCFAF4; border: 1px dashed var(--line); border-radius: var(--r-sm);
  font-size: 12.5px; color: var(--text); line-height: 1.6;
}
.check-list, .tag-picker {
  display: flex; flex-wrap: wrap; gap: 8px; padding: 10px 12px;
  border: 1px solid var(--line); border-radius: var(--r-sm); background: #FDFBF6;
  max-height: 124px; overflow-y: auto;
}
.check-list .checkline { min-width: 92px; }
.tag-opt input { display: none; }
.tag-opt span {
  display: inline-flex; align-items: center; height: 24px; padding: 0 9px; border-radius: 5px;
  font-size: 11.5px; cursor: pointer; border: 1px solid transparent; color: #3E4A44;
  transition: .15s;
}
.tag-opt.on span { border-color: var(--teal-2); box-shadow: 0 0 0 2px rgba(44, 122, 108, .12); font-weight: 600; }
.tag-opt span:hover { filter: brightness(.96); }

.pill {
  display: inline-flex; align-items: center; gap: 4px; height: 22px; padding: 0 8px;
  border-radius: 5px; font-size: 11px; font-weight: 500; white-space: nowrap;
  border: 1px solid transparent;
}
.pill i { font-size: 10px; }
.pill-teal { background: var(--teal-soft); color: #17564C; border-color: #CEE3DB; }
.pill-gold { background: var(--gold-soft); color: #8B6122; border-color: #EBD5AC; }
.pill-red { background: var(--danger-soft); color: var(--danger); border-color: #F0CFC6; }
.pill-blue { background: var(--blue-soft); color: var(--blue); border-color: #CFDDEA; }
.pill-gray { background: #F0EEE7; color: #6E7168; border-color: #E3DFD3; }
.pill-ink { background: #EDF1EF; color: var(--ink-2); }
.dot { width: 6px; height: 6px; border-radius: 50%; background: currentColor; display: inline-block; }

.level-badge {
  display: inline-flex; align-items: center; justify-content: center;
  width: 24px; height: 24px; border-radius: 7px; font-family: var(--font-serif);
  font-size: 13px; font-weight: 700; border: 1px solid;
}
.level-A { color: #8B6122; border-color: #E4CA98; background: #FBF1DC; }
.level-B { color: #17564C; border-color: #C3DCD3; background: #EAF3EF; }
.level-C { color: #35688E; border-color: #C9DAE8; background: #EBF2F8; }
.level-D { color: #6E7168; border-color: #DFDBCF; background: #F3F1EA; }

.tag-chip {
  display: inline-flex; align-items: center; height: 21px; padding: 0 7px; border-radius: 4px;
  font-size: 11px; background: #F1EFE8; color: #5A615B; border: 1px solid #E6E1D4;
}
.tag-chip + .tag-chip { margin-left: 4px; }

.avatar {
  display: inline-flex; align-items: center; justify-content: center; flex: none;
  width: 32px; height: 32px; border-radius: 9px; font-size: 12px; font-weight: 600;
  background: hsl(var(--h, 160) 32% 92%);
  color: hsl(var(--h, 160) 42% 28%);
  border: 1px solid hsl(var(--h, 160) 26% 84%);
}
.avatar.round { border-radius: 50%; }
.avatar-sm { width: 26px; height: 26px; font-size: 11px; border-radius: 7px; }
.avatar-lg { width: 44px; height: 44px; font-size: 15px; border-radius: 12px; }

/* ---------- 数据表格 ---------- */
.table-wrap { width: 100%; overflow-x: auto; }
.data-table { width: 100%; border-collapse: separate; border-spacing: 0; font-size: 12.5px; }
.data-table thead th {
  text-align: left; font-weight: 500; color: var(--muted); font-size: 11px;
  letter-spacing: .08em; padding: 0 12px 10px; border-bottom: 1px solid var(--line);
  white-space: nowrap; background: transparent;
}
.data-table tbody td {
  padding: 12px; border-bottom: 1px solid var(--line-soft); vertical-align: middle; color: var(--text-2);
}
.data-table tbody tr { transition: background .15s; }
.data-table tbody tr:hover { background: #FBF8EF; }
.data-table tbody tr:last-child td { border-bottom: none; }
.data-table .cell-main { color: var(--text); font-weight: 500; }
.data-table .cell-main.link { color: var(--teal); cursor: pointer; }
.data-table .cell-main.link:hover { text-decoration: underline; text-underline-offset: 3px; }
.data-table .num { font-variant-numeric: tabular-nums; }
.data-table .cell-sub { font-size: 11px; color: var(--muted); margin-top: 2px; }
.data-table .actions { display: flex; gap: 2px; justify-content: flex-end; white-space: nowrap; }
.data-table th.right, .data-table td.right { text-align: right; }
.row-stripe td:first-child { position: relative; }
.row-stripe td:first-child:before {
  content: ""; position: absolute; left: 0; top: 10px; bottom: 10px; width: 2px;
  border-radius: 2px; background: transparent;
}
.row-stripe.is-urgent td:first-child:before { background: var(--danger); }
.row-stripe.is-warn td:first-child:before { background: var(--amber); }

/* ---------- 卡片 ---------- */
.panel {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--r-md);
  box-shadow: var(--shadow-sm); position: relative;
}
.panel-head {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 16px 18px 12px;
}
.panel-title { display: flex; align-items: center; gap: 9px; font-size: 14px; font-weight: 600; color: var(--ink); }
.panel-title:before { content: ""; width: 3px; height: 14px; border-radius: 2px; background: linear-gradient(180deg, var(--gold), var(--teal)); }
.panel-title em { font-style: normal; font-size: 11px; color: var(--muted); font-weight: 400; letter-spacing: .04em; }
.panel-body { padding: 0 18px 18px; }
.panel-head .panel-tools { display: flex; align-items: center; gap: 8px; }

/* ---------- 弹窗 ---------- */
.modal-mask {
  position: fixed; inset: 0; background: rgba(11, 21, 18, .52);
  backdrop-filter: blur(3px); z-index: 900;
  display: flex; align-items: flex-start; justify-content: center;
  padding: 6vh 16px 40px; overflow-y: auto;
  animation: maskIn .2s ease;
}
.modal {
  width: 640px; max-width: 100%; background: var(--card); border-radius: 14px;
  box-shadow: var(--shadow-lg); position: relative; overflow: hidden;
  border: 1px solid rgba(190, 149, 83, .35);
  animation: modalIn .24s cubic-bezier(.2, .9, .3, 1.1);
}
.modal:before {
  content: ""; position: absolute; top: 0; left: 0; right: 0; height: 3px;
  background: linear-gradient(90deg, var(--teal), var(--gold) 45%, var(--gold-2) 70%, var(--teal));
}
.modal-sm { width: 460px; }
.modal-lg { width: 880px; }
.modal-xl { width: 1080px; }
.modal-head {
  display: flex; align-items: flex-start; justify-content: space-between; gap: 16px;
  padding: 20px 22px 14px; border-bottom: 1px solid var(--line-soft);
}
.modal-head h3 { font-size: 16px; color: var(--ink); letter-spacing: .02em; }
.modal-head p { font-size: 11.5px; color: var(--muted); margin-top: 2px; }
.modal-close { width: 28px; height: 28px; border-radius: 7px; color: var(--muted); display: inline-flex; align-items: center; justify-content: center; }
.modal-close:hover { background: #F3F0E8; color: var(--danger); }
.modal-body { padding: 20px 22px; max-height: 68vh; overflow-y: auto; }
.modal-foot {
  display: flex; align-items: center; justify-content: flex-end; gap: 10px;
  padding: 14px 22px; border-top: 1px solid var(--line-soft); background: #FCFAF4;
}
.modal-foot .left { margin-right: auto; font-size: 11.5px; color: var(--muted); }

.confirm-box { text-align: left; }
.confirm-icon {
  width: 42px; height: 42px; border-radius: 12px; display: inline-flex; align-items: center; justify-content: center;
  background: var(--danger-soft); color: var(--danger); font-size: 18px; float: left; margin-right: 14px;
}
.confirm-text { font-size: 13px; color: var(--text-2); padding-top: 4px; }
.confirm-text strong { color: var(--ink); }

/* ---------- 抽屉 ---------- */
.drawer-mask { position: fixed; inset: 0; background: rgba(11, 21, 18, .42); backdrop-filter: blur(2px); z-index: 800; animation: maskIn .2s ease; }
.drawer {
  position: fixed; top: 0; right: 0; bottom: 0; width: 760px; max-width: 94vw; z-index: 801;
  background: var(--card); box-shadow: -20px 0 60px rgba(14, 24, 20, .22);
  display: flex; flex-direction: column; animation: drawerIn .3s cubic-bezier(.2, .9, .3, 1);
  border-left: 1px solid var(--line);
}
.drawer-head {
  padding: 20px 24px 0; border-bottom: 1px solid var(--line-soft); background:
    radial-gradient(120% 100% at 100% 0, rgba(190, 149, 83, .1), transparent 55%), var(--card);
  position: relative;
}
.drawer-head:after { content: ""; position: absolute; left: 0; right: 0; bottom: -1px; height: 2px; background: linear-gradient(90deg, transparent, var(--gold), transparent); opacity: .45; }
.drawer-title { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }
.drawer-title h3 { font-size: 19px; color: var(--ink); letter-spacing: .02em; }
.drawer-title .sub { font-size: 11.5px; color: var(--muted); margin-top: 4px; letter-spacing: .04em; }
.drawer-body { flex: 1; overflow-y: auto; padding: 18px 24px 28px; }
.drawer-foot { padding: 12px 24px; border-top: 1px solid var(--line-soft); background: #FCFAF4; display: flex; gap: 10px; justify-content: flex-end; }

.tabs { display: flex; gap: 2px; margin-top: 18px; border-bottom: 1px solid var(--line-soft); overflow-x: auto; }
.tab {
  padding: 9px 13px; font-size: 12.5px; color: var(--muted); position: relative; white-space: nowrap;
  border-bottom: 2px solid transparent; transition: .16s;
}
.tab:hover { color: var(--teal); }
.tab.active { color: var(--ink); font-weight: 600; border-bottom-color: var(--gold); }
.tab .count { font-size: 10px; color: var(--muted); margin-left: 4px; }
.tab-pane { display: none; }
.tab-pane.active { display: block; animation: fadeUp .25s ease; }

/* ---------- 提示 ---------- */
.toast-root { position: fixed; top: 22px; left: 50%; transform: translateX(-50%); z-index: 1200; display: flex; flex-direction: column; gap: 8px; align-items: center; pointer-events: none; }
.toast {
  display: flex; align-items: center; gap: 9px; min-width: 200px; max-width: 460px;
  background: var(--ink); color: #F3EFE4; padding: 10px 16px; border-radius: 10px;
  box-shadow: 0 12px 30px rgba(14, 24, 20, .28); font-size: 12.5px;
  animation: toastIn .26s ease; border: 1px solid rgba(190, 149, 83, .3);
}
.toast i { color: var(--gold-2); font-size: 14px; }
.toast.success i { color: #8FD0B4; }
.toast.error i { color: #F0A38F; }
.toast.hide { animation: toastOut .2s ease forwards; }

/* ---------- 空状态 ---------- */
.empty-state { padding: 42px 20px; text-align: center; color: var(--muted); }
.empty-state .glyph {
  width: 54px; height: 54px; border-radius: 16px; margin: 0 auto 12px;
  background: var(--paper-2); border: 1px dashed var(--line); display: flex; align-items: center; justify-content: center;
  font-size: 22px; color: var(--gold);
}
.empty-state p { font-size: 12.5px; }
.empty-state small { font-size: 11px; color: #A9ABA1; }

/* ---------- 工具 ---------- */
.flex { display: flex; }
.between { justify-content: space-between; }
.center { align-items: center; }
.gap8 { gap: 8px; } .gap12 { gap: 12px; } .gap16 { gap: 16px; }
.mt8 { margin-top: 8px; } .mt12 { margin-top: 12px; } .mt16 { margin-top: 16px; } .mt20 { margin-top: 20px; } .mt24 { margin-top: 24px; }
.mb12 { margin-bottom: 12px; } .mb16 { margin-bottom: 16px; }
.muted { color: var(--muted); }
.small { font-size: 11.5px; }
.mono { font-family: var(--font-mono); font-size: 11.5px; letter-spacing: .02em; }
.nowrap { white-space: nowrap; }
.hidden { display: none !important; }
.text-danger { color: var(--danger); }
.text-gold { color: var(--gold); }
.text-teal { color: var(--teal); }
.divider { height: 1px; background: var(--line-soft); margin: 14px 0; }
.eyebrow {
  font-size: 10px; letter-spacing: .18em; color: var(--muted); text-transform: uppercase;
  font-family: var(--font-mono);
}

@keyframes maskIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes modalIn { from { opacity: 0; transform: translateY(-10px) scale(.98); } to { opacity: 1; transform: none; } }
@keyframes drawerIn { from { transform: translateX(40px); opacity: .6; } to { transform: none; opacity: 1; } }
@keyframes toastIn { from { opacity: 0; transform: translateY(-8px); } to { opacity: 1; transform: none; } }
@keyframes toastOut { to { opacity: 0; transform: translateY(-8px); } }
@keyframes fadeUp { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
@keyframes spin { to { transform: rotate(360deg); } }

@media (max-width: 768px) {
  .field-grid, .field-grid.col-3 { grid-template-columns: 1fr; }
  .modal-mask { padding: 3vh 10px 20px; }
  .modal-body { max-height: 72vh; padding: 16px; }
  .modal-head { padding: 16px; }
  .drawer { width: 100%; max-width: 100%; }
  .data-table thead { display: none; }
  .data-table tbody td { display: block; border: none; padding: 4px 12px; }
  .data-table tbody tr { display: block; padding: 10px 0; border-bottom: 1px solid var(--line-soft); }
  .data-table .actions { justify-content: flex-start; margin-top: 4px; }
}
