/* ============================================================
   数字驰骋 · 技术服务管理系统 — 全局样式
   ============================================================ */
:root {
  --pri: #2563eb;
  --pri-h: #1d4ed8;
  --pri-soft: #eff6ff;
  --bg: #f4f6fb;
  --card: #ffffff;
  --txt: #1f2937;
  --txt2: #6b7280;
  --txt3: #9ca3af;
  --border: #e5e7eb;
  --ok: #16a34a;
  --ok-soft: #f0fdf4;
  --warn: #d97706;
  --warn-soft: #fffbeb;
  --err: #dc2626;
  --err-soft: #fef2f2;
  --info: #2563eb;
  --info-soft: #eff6ff;
  --sidebar-w: 232px;
  --topbar-h: 56px;
  --radius: 10px;
  --shadow: 0 1px 3px rgba(0,0,0,.06), 0 1px 2px rgba(0,0,0,.04);
  --shadow-lg: 0 10px 30px rgba(0,0,0,.12);
  --font: -apple-system, BlinkMacSystemFont, 'PingFang SC', 'Microsoft YaHei', 'Segoe UI', Roboto, sans-serif;
}
* { margin: 0; padding: 0; box-sizing: border-box; }
html, body { height: 100%; }
body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--txt);
  font-size: 14px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--pri); text-decoration: none; }
a:hover { color: var(--pri-h); }

/* ---------- 通用按钮 ---------- */
.btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 8px 16px; border-radius: 8px; font-size: 14px; font-weight: 500;
  border: 1px solid transparent; cursor: pointer; transition: all .15s;
  background: #fff; color: var(--txt); border-color: var(--border);
  white-space: nowrap;
}
.btn:hover { background: #f9fafb; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn-pri { background: var(--pri); color: #fff; border-color: var(--pri); }
.btn-pri:hover { background: var(--pri-h); }
.btn-danger { background: #fff; color: var(--err); border-color: #fecaca; }
.btn-danger:hover { background: var(--err-soft); }
.btn-ghost { background: transparent; border-color: transparent; color: var(--txt2); }
.btn-ghost:hover { background: #f3f4f6; color: var(--txt); }
.btn-sm { padding: 5px 10px; font-size: 13px; border-radius: 6px; }
.btn-block { width: 100%; justify-content: center; }

/* ---------- 表单 ---------- */
.field { margin-bottom: 16px; }
.field label { display: block; font-size: 13px; font-weight: 500; color: var(--txt); margin-bottom: 6px; }
.field label .req { color: var(--err); margin-left: 2px; }
.field .hint { font-size: 12px; color: var(--txt3); margin-top: 4px; }
input[type=text], input[type=password], input[type=email], input[type=tel],
input[type=number], input[type=date], input[type=search], select, textarea {
  width: 100%; padding: 9px 12px; border: 1px solid var(--border); border-radius: 8px;
  font-size: 14px; font-family: var(--font); color: var(--txt); background: #fff;
  transition: border-color .15s, box-shadow .15s; outline: none;
}
input:focus, select:focus, textarea:focus {
  border-color: var(--pri); box-shadow: 0 0 0 3px rgba(37,99,235,.12);
}
textarea { resize: vertical; min-height: 80px; }

/* ---------- 卡片 ---------- */
.card {
  background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 20px; border: 1px solid var(--border);
}
.card + .card { margin-top: 16px; }
.card-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 16px; }
.card-head h3 { font-size: 15px; font-weight: 600; }

/* ---------- 表格 ---------- */
.table-wrap { overflow-x: auto; }
table.tbl { width: 100%; border-collapse: collapse; font-size: 14px; }
table.tbl thead th {
  text-align: left; padding: 10px 12px; font-size: 12px; font-weight: 600;
  color: var(--txt2); background: #f9fafb; border-bottom: 1px solid var(--border);
  white-space: nowrap; text-transform: none;
}
table.tbl tbody td {
  padding: 12px; border-bottom: 1px solid var(--border); vertical-align: middle;
}
table.tbl tbody tr:hover { background: #fafbff; }
table.tbl tbody tr:last-child td { border-bottom: none; }
.tbl-empty { text-align: center; color: var(--txt3); padding: 40px 0 !important; }

/* 徽章 */
.badge {
  display: inline-flex; align-items: center; gap: 4px; padding: 2px 10px;
  border-radius: 20px; font-size: 12px; font-weight: 500; white-space: nowrap;
}
.badge.ok { background: var(--ok-soft); color: var(--ok); }
.badge.warn { background: var(--warn-soft); color: var(--warn); }
.badge.err { background: var(--err-soft); color: var(--err); }
.badge.info { background: var(--info-soft); color: var(--info); }
.badge.gray { background: #f3f4f6; color: var(--txt2); }

/* ---------- 分页 ---------- */
.pager { display: flex; align-items: center; justify-content: space-between; margin-top: 16px; flex-wrap: wrap; gap: 12px; }
.pager .info { font-size: 13px; color: var(--txt2); }
.pager .btns { display: flex; gap: 6px; align-items: center; }
.pager .btn { padding: 6px 12px; }

/* ---------- 模态框 ---------- */
.modal-mask {
  position: fixed; inset: 0; background: rgba(15,23,42,.45); z-index: 100;
  display: flex; align-items: center; justify-content: center; padding: 20px;
  animation: fadeIn .15s;
}
.modal {
  background: #fff; border-radius: 14px; width: 100%; max-width: 560px;
  max-height: 90vh; overflow: hidden; display: flex; flex-direction: column;
  box-shadow: var(--shadow-lg); animation: slideUp .2s;
}
.modal-head { padding: 18px 22px; border-bottom: 1px solid var(--border); display: flex; align-items: center; justify-content: space-between; }
.modal-head h3 { font-size: 16px; font-weight: 600; }
.modal-close { border: none; background: none; font-size: 22px; color: var(--txt3); cursor: pointer; line-height: 1; }
.modal-close:hover { color: var(--txt); }
.modal-body { padding: 22px; overflow-y: auto; }
.modal-foot { padding: 14px 22px; border-top: 1px solid var(--border); display: flex; justify-content: flex-end; gap: 10px; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0 16px; }
.form-grid .full { grid-column: 1 / -1; }

@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes slideUp { from { opacity: 0; transform: translateY(12px); } to { opacity: 1; transform: none; } }

/* ---------- Toast ---------- */
.toast-wrap { position: fixed; top: 20px; left: 50%; transform: translateX(-50%); z-index: 200; display: flex; flex-direction: column; gap: 10px; align-items: center; }
.toast {
  padding: 11px 20px; border-radius: 10px; font-size: 14px; color: #fff;
  box-shadow: var(--shadow-lg); animation: slideUp .2s; max-width: 420px;
}
.toast.ok { background: var(--ok); }
.toast.err { background: var(--err); }
.toast.warn { background: var(--warn); }
.toast.info { background: #334155; }

/* ---------- 加载动画 ---------- */
.spinner {
  width: 16px; height: 16px; border: 2px solid #fff; border-top-color: transparent;
  border-radius: 50%; animation: spin .6s linear infinite; display: inline-block;
}
.spinner.dark { border-color: var(--txt3); border-top-color: transparent; }
@keyframes spin { to { transform: rotate(360deg); } }

.loading-mask {
  position: fixed; inset: 0; background: rgba(255,255,255,.7); z-index: 300;
  display: flex; align-items: center; justify-content: center;
}
.loading-mask .spinner { width: 32px; height: 32px; border-width: 3px; border-color: var(--pri); border-top-color: transparent; }

/* ---------- 应用布局（侧边栏 + 顶栏） ---------- */
.app-shell { display: flex; min-height: 100vh; }
.sidebar {
  width: var(--sidebar-w); background: #0f172a; color: #cbd5e1;
  position: fixed; top: 0; left: 0; bottom: 0; z-index: 50;
  display: flex; flex-direction: column; transition: transform .2s;
}
.sidebar .brand { display: flex; align-items: center; gap: 10px; padding: 18px 20px; border-bottom: 1px solid rgba(255,255,255,.08); }
.sidebar .brand .logo {
  width: 34px; height: 34px; border-radius: 8px; background: linear-gradient(135deg,#2563eb,#60a5fa);
  display: flex; align-items: center; justify-content: center; color: #fff; font-weight: 700; font-size: 16px; flex-shrink: 0;
}
.sidebar .brand .name { font-size: 15px; font-weight: 600; color: #fff; }
.sidebar .brand .sub { font-size: 11px; color: #64748b; }
.sidebar nav { flex: 1; overflow-y: auto; padding: 12px 10px; }
.sidebar nav .group { font-size: 11px; color: #64748b; text-transform: uppercase; letter-spacing: .5px; padding: 14px 12px 6px; }
.sidebar nav a {
  display: flex; align-items: center; gap: 10px; padding: 9px 12px; border-radius: 8px;
  color: #cbd5e1; font-size: 14px; margin-bottom: 2px; transition: all .12s;
}
.sidebar nav a:hover { background: rgba(255,255,255,.06); color: #fff; }
.sidebar nav a.active { background: var(--pri); color: #fff; }
.sidebar nav a .ico { width: 18px; text-align: center; flex-shrink: 0; }
.sidebar .foot { padding: 14px 20px; border-top: 1px solid rgba(255,255,255,.08); font-size: 12px; color: #64748b; }

.main { flex: 1; margin-left: var(--sidebar-w); display: flex; flex-direction: column; min-height: 100vh; }
.topbar {
  height: var(--topbar-h); background: #fff; border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between; padding: 0 24px;
  position: sticky; top: 0; z-index: 40;
}
.topbar .title { font-size: 16px; font-weight: 600; }
.topbar .right { display: flex; align-items: center; gap: 14px; }
.topbar .user { display: flex; align-items: center; gap: 8px; }
.topbar .avatar {
  width: 30px; height: 30px; border-radius: 50%; background: var(--pri-soft); color: var(--pri);
  display: flex; align-items: center; justify-content: center; font-weight: 600; font-size: 13px;
}
.content { flex: 1; padding: 24px; max-width: 1280px; width: 100%; margin: 0 auto; }
.page-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 20px; flex-wrap: wrap; gap: 12px; }
.page-head h1 { font-size: 20px; font-weight: 700; }
.page-head .desc { font-size: 13px; color: var(--txt2); margin-top: 2px; }
.page-head .actions { display: flex; gap: 10px; }

/* 统计卡片 */
.stat-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 16px; margin-bottom: 20px; }
.stat-card { background: #fff; border-radius: var(--radius); box-shadow: var(--shadow); border: 1px solid var(--border); padding: 18px 20px; display: flex; align-items: center; gap: 14px; }
.stat-card .ico { width: 44px; height: 44px; border-radius: 12px; display: flex; align-items: center; justify-content: center; font-size: 20px; flex-shrink: 0; }
.stat-card .ico.blue { background: var(--info-soft); }
.stat-card .ico.green { background: var(--ok-soft); }
.stat-card .ico.orange { background: var(--warn-soft); }
.stat-card .ico.purple { background: #f5f3ff; }
.stat-card .ico.red { background: var(--err-soft); }
.stat-card .val { font-size: 24px; font-weight: 700; line-height: 1.2; }
.stat-card .lbl { font-size: 13px; color: var(--txt2); }

/* 工具栏 */
.toolbar { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.toolbar .spacer { flex: 1; }
.toolbar input[type=search], .toolbar select { width: auto; min-width: 180px; }

/* 页脚（含备案信息） */
.site-footer {
  text-align: center; padding: 18px 24px; color: var(--txt3); font-size: 12px;
  border-top: 1px solid var(--border); background: #fff;
}
.site-footer a { color: var(--txt3); }
.site-footer a:hover { color: var(--txt2); }
.site-footer .icp { margin-top: 4px; }
.site-footer .icp a { display: inline-flex; align-items: center; gap: 4px; }

/* ---------- 登录页 / 营销页 ---------- */
.auth-page { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 20px; background: linear-gradient(135deg,#0f172a 0%,#1e3a8a 50%,#2563eb 100%); position: relative; }
.auth-card { background: #fff; border-radius: 16px; box-shadow: var(--shadow-lg); width: 100%; max-width: 400px; padding: 36px; }
.auth-card .logo { display: flex; align-items: center; gap: 10px; justify-content: center; margin-bottom: 8px; }
.auth-card .logo .mark { width: 40px; height: 40px; border-radius: 10px; background: linear-gradient(135deg,#2563eb,#60a5fa); color: #fff; display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: 20px; }
.auth-card h1 { font-size: 20px; text-align: center; margin-bottom: 4px; }
.auth-card .sub { text-align: center; color: var(--txt2); font-size: 13px; margin-bottom: 24px; }
.auth-card .err-box { background: var(--err-soft); color: var(--err); padding: 10px 14px; border-radius: 8px; font-size: 13px; margin-bottom: 16px; display: none; }
.auth-foot { text-align: center; margin-top: 18px; font-size: 12px; color: var(--txt3); }

/* 响应式 */
@media (max-width: 900px) {
  .sidebar { transform: translateX(-100%); }
  .sidebar.open { transform: translateX(0); box-shadow: var(--shadow-lg); }
  .main { margin-left: 0; }
  .menu-toggle { display: inline-flex !important; }
}
.menu-toggle { display: none; }
.sidebar-mask { position: fixed; inset: 0; background: rgba(0,0,0,.4); z-index: 49; display: none; }
.sidebar-mask.show { display: block; }

/* ---------- ref 关联下拉（＋新增 / ↻刷新） ---------- */
.ref-wrap { display: flex; align-items: center; gap: 6px; }
.ref-wrap select { flex: 1; min-width: 0; }
.ref-add { font-size: 12px; color: var(--pri); white-space: nowrap; text-decoration: none; }
.ref-add:hover { color: var(--pri-h); }
.ref-refresh { padding: 5px 8px; flex-shrink: 0; }

/* ---------- AI / 语音录入（v6） ---------- */
.form-ai-bar {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  padding: 10px 12px; margin-bottom: 14px; border-radius: 8px;
  background: var(--pri-soft); border: 1px solid #dbeafe;
}
.ai-bar-hint { font-size: 12px; color: var(--txt2); }
.voice-box {
  margin-bottom: 14px; padding: 12px; border-radius: 8px;
  background: #f8fafc; border: 1px dashed var(--border);
}
.voice-box-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; font-size: 13px; font-weight: 600; color: var(--txt); }
.voice-box textarea { min-height: 70px; background: #fff; }
.voice-box-foot { margin-top: 8px; }

/* ---------- 客户画像（360° 聚合） ---------- */
.profile-stats { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
@media (max-width: 600px) { .profile-stats { grid-template-columns: 1fr; } }
.ps-item { background: #f8fafc; border: 1px solid var(--border); border-radius: 8px; padding: 10px 12px; }
.ps-val { font-size: 14px; font-weight: 600; color: var(--txt); line-height: 1.5; }
.ps-lbl { font-size: 12px; color: var(--txt3); margin-top: 2px; }
.profile-chains { display: grid; grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: 10px; margin-top: 10px; }
.profile-chain { display: flex; align-items: center; gap: 10px; background: #fff; border: 1px solid var(--border); border-radius: 8px; padding: 10px 12px; }
.profile-chain .pc-icon { font-size: 20px; }
.profile-chain .pc-label { font-size: 12px; color: var(--txt2); }
.profile-chain .pc-count { font-size: 15px; font-weight: 700; color: var(--txt); }
