/* ============================================================
   火灵CRM 2.0 样式表
   风格: 现代扁平化 + 渐变 + 柔和阴影
   ============================================================ */
:root {
  --sidebar-bg: linear-gradient(180deg, #0e1a2f 0%, #162d4d 100%);
  --sidebar-active: var(--primary);
  --primary: #2563eb;
  --primary-dark: #1d4ed8;
  --primary-light: #dbeafe;
  --text-main: #0f172a;
  --text-sub: #64748b;
  --bg-main: #f1f5f9;
  --card-bg: #ffffff;
  --border: #e2e8f0;
  --success: #16a34a;
  --warn: #d97706;
  --danger: #dc2626;
  --radius: 12px;
  --radius-sm: 8px;
  --shadow: 0 1px 3px rgba(15, 23, 42, .06), 0 4px 12px rgba(15, 23, 42, .04);
  --shadow-lg: 0 10px 30px rgba(15, 23, 42, .1);
}
* { margin: 0; padding: 0; box-sizing: border-box; }
body { font-family: "Microsoft YaHei", "PingFang SC", -apple-system, sans-serif; background: var(--bg-main); color: var(--text-main); font-size: 14px; line-height: 1.6; }
a { color: var(--primary); text-decoration: none; }
input, select, textarea { font-family: inherit; font-size: 14px; }

/* ---------- 登录页 ---------- */
.login-body { background: linear-gradient(135deg, #0f172a 0%, #1e293b 55%, var(--primary) 100%); min-height: 100vh; display: flex; align-items: center; justify-content: center; }
.login-wrap { width: 100%; max-width: 400px; padding: 20px; }
.login-card { background: #fff; border-radius: 16px; padding: 40px 36px 28px; box-shadow: 0 24px 60px rgba(0,0,0,.35); }
.login-brand { text-align: center; margin-bottom: 28px; }
.login-side { display: flex; flex-direction: column; }
.login-logo { width: 64px; height: 64px; border-radius: 16px; background: var(--primary); color: #fff; font-size: 32px; font-weight: 700; display: flex; align-items: center; justify-content: center; margin: 0 auto 14px; box-shadow: 0 8px 20px var(--primary-light); }
.login-title { font-size: 22px; font-weight: 700; }
.login-title span { color: var(--primary); font-size: 14px; font-weight: 400; margin-left: 4px; }
.login-sub { color: var(--text-sub); font-size: 12px; margin-top: 6px; }
.login-msg { color: var(--danger); font-size: 13px; min-height: 20px; margin: 6px 0; }
.login-foot { text-align: center; color: #94a3b8; font-size: 12px; margin-top: 18px; }

/* ---------- 表单 ---------- */
.form-item { margin-bottom: 16px; }
.form-item label { display: block; font-size: 13px; color: var(--text-sub); margin-bottom: 6px; font-weight: 500; }
.form-item input, .form-item select, .form-item textarea { width: 100%; padding: 10px 14px; border: 1px solid var(--border); border-radius: var(--radius-sm); outline: none; background: #fff; transition: all .15s; }
.form-item input:focus, .form-item select:focus, .form-item textarea:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(37,99,235,.12); }
.form-item textarea { resize: vertical; min-height: 72px; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.form-grid-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 14px; }

/* ---------- 按钮 ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; padding: 9px 20px; border-radius: var(--radius-sm); border: 1px solid transparent; cursor: pointer; font-size: 14px; font-weight: 500; transition: all .15s; white-space: nowrap; }
.btn-primary { background: var(--primary); color: #fff; box-shadow: 0 2px 8px var(--primary-light); }
.btn-primary:hover { transform: translateY(-1px); box-shadow: 0 4px 12px rgba(37,99,235,.35); }
.btn-outline { background: #fff; border-color: var(--border); color: var(--text-main); }
.btn-outline:hover { border-color: var(--primary); color: var(--primary); background: #f8fafc; }
.btn-danger { background: #fff; border-color: #fecaca; color: var(--danger); }
.btn-danger:hover { background: #fef2f2; }
.btn-sm { padding: 5px 12px; font-size: 12px; border-radius: 6px; }
.btn-block { width: 100%; padding: 12px; font-size: 15px; }
.btn:disabled { opacity: .6; cursor: not-allowed; transform: none !important; }

/* ---------- 工作台布局 ---------- */
.app { display: flex; min-height: 100vh; }
.sidebar { width: 220px; background: var(--sidebar-bg); color: #cbd5e1; display: flex; flex-direction: column; position: fixed; top: 0; bottom: 0; left: 0; z-index: 50; }
.sidebar-brand { padding: 20px; display: flex; align-items: center; gap: 12px; border-bottom: 1px solid rgba(255,255,255,.08); }
.sidebar-logo { width: 38px; height: 38px; border-radius: 10px; background: var(--primary); color: #fff; font-weight: 700; display: flex; align-items: center; justify-content: center; font-size: 18px; box-shadow: 0 4px 12px var(--primary-light); }
.sidebar-brand-text { font-size: 15px; font-weight: 600; color: #fff; }
.sidebar-brand-text small { display: block; font-size: 11px; color: #7c8aa5; font-weight: 400; margin-top: 2px; }
.sidebar-nav { flex: 1; padding: 14px 10px; overflow-y: auto; }
.nav-item { display: flex; align-items: center; gap: 10px; padding: 11px 14px; border-radius: var(--radius-sm); cursor: pointer; color: #cbd5e1; margin-bottom: 4px; transition: all .15s; font-size: 14px; }
.nav-item:hover { background: rgba(255,255,255,.08); color: #fff; }
.nav-item.active { background: var(--sidebar-active); color: #fff; box-shadow: 0 4px 12px rgba(37,99,235,.3); }
.nav-item .nav-ico { width: 18px; text-align: center; font-size: 16px; }
.sidebar-foot { padding: 14px 20px; border-top: 1px solid rgba(255,255,255,.08); font-size: 11px; color: #64748b; }

.main { flex: 1; margin-left: 220px; display: flex; flex-direction: column; min-height: 100vh; }
.topbar { height: 60px; background: #fff; border-bottom: 1px solid var(--border); display: flex; align-items: center; justify-content: space-between; padding: 0 28px; position: sticky; top: 0; z-index: 40; box-shadow: 0 1px 3px rgba(0,0,0,.03); }
.topbar-title { font-size: 17px; font-weight: 600; }
.topbar-user { display: flex; align-items: center; gap: 14px; }
.topbar-user .user-chip { display: flex; align-items: center; gap: 8px; }
.avatar { width: 34px; height: 34px; border-radius: 50%; background: var(--primary); color: #fff; display: flex; align-items: center; justify-content: center; font-size: 14px; font-weight: 600; }
.content { padding: 24px 28px; flex: 1; }

/* ---------- 卡片与统计 ---------- */
.card { background: var(--card-bg); border-radius: var(--radius); box-shadow: var(--shadow); padding: 22px; margin-bottom: 18px; border: 1px solid var(--border); }
.card-title { font-size: 15px; font-weight: 600; margin-bottom: 16px; display: flex; align-items: center; justify-content: space-between; }
.stat-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; margin-bottom: 20px; }
.stat-card { background: #fff; border-radius: var(--radius); box-shadow: var(--shadow); padding: 20px; display: flex; align-items: center; gap: 14px; border: 1px solid var(--border); transition: transform .15s; }
.stat-card:hover { transform: translateY(-2px); box-shadow: var(--shadow-lg); }
.stat-ico { width: 52px; height: 52px; border-radius: 14px; display: flex; align-items: center; justify-content: center; font-size: 24px; color: #fff; flex-shrink: 0; }
.stat-ico.blue { background: var(--primary); box-shadow: 0 4px 12px var(--primary-light); }
.stat-ico.green { background: linear-gradient(135deg, #22c55e, #16a34a); box-shadow: 0 4px 12px rgba(34,197,94,.3); }
.stat-ico.orange { background: linear-gradient(135deg, #f59e0b, #d97706); box-shadow: 0 4px 12px rgba(245,158,11,.3); }
.stat-ico.purple { background: linear-gradient(135deg, #8b5cf6, #6d28d9); box-shadow: 0 4px 12px rgba(139,92,246,.3); }
.stat-ico.red { background: linear-gradient(135deg, #ef4444, #dc2626); box-shadow: 0 4px 12px rgba(239,68,68,.3); }
.stat-num { font-size: 28px; font-weight: 700; line-height: 1.1; }
.stat-label { font-size: 12px; color: var(--text-sub); margin-top: 4px; }

/* ---------- 表格 ---------- */
.tbl-wrap { overflow-x: auto; max-height: calc(100vh - 260px); overflow-y: auto; }
table.tbl { width: 100%; border-collapse: collapse; }
table.tbl th, table.tbl td { padding: 12px 14px; text-align: left; border-bottom: 1px solid var(--border); white-space: nowrap; }
table.tbl th { background: #f8fafc; font-size: 12px; color: var(--text-sub); font-weight: 600; text-transform: uppercase; letter-spacing: .3px; }
/* Excel 式冻结：表头行固定（行冻结）+ 首列固定（列冻结），横向/纵向滚动均不跟随 */
table.tbl thead th { position: sticky; top: 0; z-index: 4; box-shadow: 0 1px 0 var(--border); }
table.tbl th:first-child, table.tbl tbody td:first-child { position: sticky; left: 0; z-index: 2; }
table.tbl thead th:first-child { z-index: 5; }
table.tbl tbody td:first-child { background: #fff; }
table.tbl tr:hover td { background: #f8fafc; }
table.tbl tr:hover td:first-child { background: #f8fafc; }
.tbl-empty { text-align: center; color: #9ca3af; padding: 40px 0; }

/* ---------- 标签 ---------- */
.tag { display: inline-block; padding: 3px 12px; border-radius: 20px; font-size: 12px; font-weight: 500; }
.tag-blue { background: var(--primary-light); color: var(--primary-dark); }
.tag-green { background: #dcfce7; color: #15803d; }
.tag-orange { background: #fef3c7; color: #b45309; }
.tag-red { background: #fee2e2; color: #b91c1c; }
.tag-gray { background: #f1f5f9; color: #475569; }
.tag-purple { background: #ede9fe; color: #6d28d9; }

/* ---------- 搜索栏与工具条 ---------- */
.toolbar { display: flex; align-items: center; gap: 10px; margin-bottom: 18px; flex-wrap: nowrap; overflow-x: auto; max-width: 100%; }
.toolbar input[type=text], .toolbar select { padding: 9px 14px; border: 1px solid var(--border); border-radius: var(--radius-sm); outline: none; background: #fff; transition: border .15s; }
.toolbar input[type=text]:focus, .toolbar select:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(37,99,235,.1); }
.toolbar .grow { flex: 1; }
.page-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 18px; }
.page-head h2 { font-size: 20px; font-weight: 600; }

/* ---------- 详情布局 ---------- */
.detail-grid { display: grid; grid-template-columns: 360px 1fr; gap: 18px; }
.detail-row { display: flex; padding: 10px 0; border-bottom: 1px dashed var(--border); font-size: 13.5px; }
.detail-row .k { width: 110px; color: var(--text-sub); flex-shrink: 0; }
.detail-row .v { flex: 1; word-break: break-all; }

/* ---------- 弹窗 ---------- */
.modal-mask { position: fixed; inset: 0; background: rgba(15,23,42,.5); backdrop-filter: blur(4px); z-index: 100; display: none; align-items: flex-start; justify-content: center; padding: 60px 20px; overflow-y: auto; }
.modal-mask.show { display: flex; }
.modal { background: #fff; border-radius: 16px; width: 100%; max-width: 720px; min-height: 200px; box-shadow: 0 24px 60px rgba(0,0,0,.25); animation: modalIn .2s ease; }
.modal-head { padding: 18px 24px; 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 { cursor: pointer; color: #9ca3af; font-size: 22px; line-height: 1; background: none; border: none; width: 32px; height: 32px; border-radius: 8px; display: flex; align-items: center; justify-content: center; }
.modal-close:hover { background: #f1f5f9; color: #475569; }
.modal-body { padding: 24px; }
.modal-foot { padding: 16px 24px; border-top: 1px solid var(--border); display: flex; justify-content: flex-end; gap: 10px; }
@keyframes modalIn { from { transform: translateY(-16px) scale(.98); opacity: 0; } to { transform: none; opacity: 1; } }

/* ---------- 杂项 ---------- */
.muted { color: var(--text-sub); font-size: 12px; }
.flex { display: flex; align-items: center; gap: 10px; }
.flex-between { display: flex; align-items: center; justify-content: space-between; }
.gap-sm { gap: 6px; }
.mt16 { margin-top: 16px; }
.mb12 { margin-bottom: 12px; }
.timeline { position: relative; padding-left: 20px; }
.timeline::before { content: ''; position: absolute; left: 6px; top: 4px; bottom: 4px; width: 2px; background: var(--border); }
.tl-item { position: relative; padding: 8px 0 14px; }
.tl-item::before { content: ''; position: absolute; left: -17px; top: 13px; width: 8px; height: 8px; border-radius: 50%; background: var(--primary); }
.tl-item .tl-head { font-size: 13px; }
.tl-item .tl-time { font-size: 12px; color: var(--text-sub); margin-top: 2px; }
.tl-item .tl-body { margin-top: 6px; color: #374151; line-height: 1.6; background: #f8fafc; border-radius: 8px; padding: 10px 12px; }

.pagination { display: flex; align-items: center; gap: 8px; justify-content: flex-end; margin-top: 16px; }
.pagination button { padding: 6px 14px; border: 1px solid var(--border); background: #fff; border-radius: 6px; cursor: pointer; }
.pagination button:disabled { opacity: .4; cursor: not-allowed; }

.notice { padding: 12px 16px; border-radius: var(--radius-sm); margin-bottom: 14px; font-size: 13px; }
.notice-info { background: var(--primary-light); color: var(--primary-dark); border: 1px solid var(--primary-light); }
.notice-ok { background: #f0fdf4; color: #15803d; border: 1px solid #bbf7d0; }
.notice-err { background: #fef2f2; color: #b91c1c; border: 1px solid #fecaca; }

.toast { position: fixed; top: 80px; left: 50%; transform: translateX(-50%); background: #111827; color: #fff; padding: 12px 24px; border-radius: 10px; z-index: 200; font-size: 14px; box-shadow: 0 8px 30px rgba(0,0,0,.25); opacity: 0; transition: opacity .2s; pointer-events: none; }
.toast.show { opacity: 1; }
.toast.ok { background: #15803d; }
.toast.err { background: #b91c1c; }

/* ---- 客户tab切换 ---- */
.tabs { display:flex; gap:4px; margin-bottom:16px; }
.tab-btn { padding:8px 18px; border:1px solid var(--border); background:#fff; border-radius:8px; cursor:pointer; font-size:14px; }
.tab-btn.active { background:var(--primary); color:#fff; border-color:var(--primary); }

/* ---- 卡片折叠 ---- */
.card.collapsed .card-body { display:none; }
.card-title { cursor:default; user-select:none; }
.card-toggle { float:right; cursor:pointer; color:var(--text-sub); font-size:16px; line-height:1; }
.card-toggle:hover { color:var(--primary); }

/* ---- 手机自适应 ---- */
@media (max-width: 768px) {
  .sidebar { width:60px; }
  .sidebar .nav-item span:not(.nav-ico) { display:none; }
  .main { margin-left:60px; }
  .detail-grid { grid-template-columns: 1fr !important; }
  .stat-grid { grid-template-columns: 1fr 1fr !important; }
  .tbl-wrap { overflow-x:auto; }
  .toolbar { flex-wrap:nowrap; overflow-x:auto; }
  .form-item { flex:1 1 100%; }
}
/* 皮肤主题 */
.skin-green { --primary:#059669; --primary-dark:#047857; }
.skin-purple { --primary:#7c3aed; --primary-dark:#6d28d9; }
.skin-dark { --primary:#334155; --primary-dark:#1e293b; --bg-main:#0f172a; --card-bg:#1e293b; --text-main:#e2e8f0; --border:#334155; }
.skin-dark .sidebar { background:#0f172a; }
.skin-dark .topbar { background:#1e293b; border-color:#334155; }
.skin-dark .card { background:#1e293b; border-color:#334155; }
.skin-dark .tbl th { background:#0f172a; color:#94a3b8; }
.skin-dark .tbl tbody td:first-child { background:#1e293b; }
.skin-dark .tbl tr:hover td:first-child { background:#0f172a; }
.skin-dark .modal-body { background:#1e293b; color:#e2e8f0; }
.skin-dark .form-item input, .skin-dark .form-item select, .skin-dark .form-item textarea { background:#0f172a; color:#e2e8f0; border-color:#334155; }


/* ========== 场景主题切换 ========== */
/* 默认=软件公司（蓝紫科技感） */
body {
  --primary: #6366f1;
  --primary-dark: #4f46e5;
  --primary-light: #e0e7ff;
  --sidebar-bg: linear-gradient(180deg, #1e1b4b 0%, #312e81 100%);
  --sidebar-active: linear-gradient(135deg, #818cf8, #4f46e5);
  --accent: #8b5cf6;
}

/* 制造业（深蓝稳重） */
body.scene-mfg {
  --primary: #0ea5e9;
  --primary-dark: #0369a1;
  --primary-light: #e0f2fe;
  --sidebar-bg: linear-gradient(180deg, #0c4a6e 0%, #075985 100%);
  --sidebar-active: linear-gradient(135deg, #38bdf8, #0369a1);
  --accent: #06b6d4;
}

/* 工程行业（橙红工程感） */
body.scene-eng {
  --primary: #f97316;
  --primary-dark: #ea580c;
  --primary-light: #ffedd5;
  --sidebar-bg: linear-gradient(180deg, #431407 0%, #7c2d12 100%);
  --sidebar-active: linear-gradient(135deg, #fb923c, #ea580c);
  --accent: #dc2626;
}

/* 服务行业（绿色商务感） */
body.scene-service {
  --primary: #10b981;
  --primary-dark: #047857;
  --primary-light: #d1fae5;
  --sidebar-bg: linear-gradient(180deg, #064e3b 0%, #065f46 100%);
  --sidebar-active: linear-gradient(135deg, #34d399, #047857);
  --accent: #14b8a6;
}

/* 场景切换器 */
.scene-switcher {
  display: flex; align-items: center; gap: 4px;
  background: #f1f5f9; border-radius: 10px; padding: 3px;
}
.scene-btn {
  padding: 5px 12px; border-radius: 8px; cursor: pointer;
  font-size: 12px; border: none; background: transparent;
  color: #64748b; transition: all .15s;
}
.scene-btn:hover { color: #0f172a; }
.scene-btn.active {
  background: #fff; color: var(--primary); font-weight: 600;
  box-shadow: 0 1px 3px rgba(0,0,0,.1);
}
