/* ==========================================================================
   爱曜 · 私域精准客户霸屏系统 —— 设计系统
   主色：蓝紫渐变 #2563eb → #8b5cf6
   ========================================================================== */
:root {
  --pri: #2563eb;
  --pri-2: #8b5cf6;
  --pri-3: #06b6d4;
  --grad: linear-gradient(135deg, #2563eb 0%, #8b5cf6 100%);
  --grad-soft: linear-gradient(135deg, rgba(37, 99, 235, .10) 0%, rgba(139, 92, 246, .10) 100%);

  --bg: #f5f7fb;
  --surface: #ffffff;
  --surface-2: #fafbfe;
  --line: #e6eaf2;
  --line-2: #eef1f7;

  --text: #101828;
  --text-2: #475467;
  --text-3: #98a2b3;

  --ok: #12b76a;
  --ok-bg: #ecfdf3;
  --warn: #f79009;
  --warn-bg: #fffaeb;
  --danger: #f04438;
  --danger-bg: #fef3f2;
  --info: #2563eb;
  --info-bg: #eff4ff;

  --radius: 12px;
  --radius-lg: 16px;
  --shadow-sm: 0 1px 2px rgba(16, 24, 40, .05);
  --shadow: 0 4px 16px rgba(16, 24, 40, .07);
  --shadow-lg: 0 16px 40px rgba(16, 24, 40, .12);

  --sidebar-w: 232px;
  --topbar-h: 60px;
  --font: -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--pri); text-decoration: none; }
a:hover { opacity: .82; }
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-thumb { background: #d4dae6; border-radius: 8px; }
::-webkit-scrollbar-thumb:hover { background: #bcc5d6; }
::-webkit-scrollbar-track { background: transparent; }

/* ------------------------------- 布局 ------------------------------- */
.layout { display: flex; min-height: 100vh; }

.sidebar {
  width: var(--sidebar-w);
  flex: 0 0 var(--sidebar-w);
  background: #fff;
  border-right: 1px solid var(--line);
  position: fixed;
  inset: 0 auto 0 0;
  display: flex;
  flex-direction: column;
  z-index: 30;
}
.brand {
  height: var(--topbar-h);
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 18px;
  border-bottom: 1px solid var(--line-2);
  flex: 0 0 auto;
}
.brand-logo {
  width: 32px; height: 32px; border-radius: 9px;
  background: var(--grad);
  display: grid; place-items: center;
  color: #fff; font-weight: 800; font-size: 15px;
  box-shadow: 0 4px 12px rgba(37, 99, 235, .3);
}
.brand-txt { font-weight: 700; font-size: 15px; letter-spacing: .3px; }
.brand-sub { font-size: 11px; color: var(--text-3); font-weight: 400; margin-top: -3px; }

.nav { padding: 12px 10px; overflow-y: auto; flex: 1; }
.nav-group { font-size: 11px; color: var(--text-3); font-weight: 600; letter-spacing: .6px; padding: 14px 10px 6px; }
.nav-item {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 11px; border-radius: 9px;
  color: var(--text-2); cursor: pointer;
  font-size: 13.5px; font-weight: 500;
  margin-bottom: 2px; transition: .16s;
  user-select: none;
}
.nav-item:hover { background: var(--surface-2); color: var(--text); }
.nav-item.active { background: var(--grad-soft); color: var(--pri); font-weight: 600; }
.nav-item.active .ico { color: var(--pri); }
.ico { width: 18px; height: 18px; flex: 0 0 18px; display: grid; place-items: center; color: var(--text-3); }
.ico svg { width: 17px; height: 17px; stroke-width: 1.9; }
.nav-badge { margin-left: auto; font-size: 11px; background: var(--danger); color: #fff; border-radius: 20px; padding: 0 6px; line-height: 16px; }

.sidebar-foot { padding: 12px; border-top: 1px solid var(--line-2); }
.user-chip { display: flex; align-items: center; gap: 9px; padding: 8px; border-radius: 10px; background: var(--surface-2); }
.avatar { width: 32px; height: 32px; border-radius: 50%; background: var(--grad); color: #fff; display: grid; place-items: center; font-weight: 700; font-size: 13px; flex: 0 0 32px; }
.user-chip .meta { min-width: 0; flex: 1; }
.user-chip .n { font-size: 13px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-chip .r { font-size: 11px; color: var(--text-3); }

.main { flex: 1; margin-left: var(--sidebar-w); min-width: 0; display: flex; flex-direction: column; }
.topbar {
  height: var(--topbar-h);
  background: rgba(255, 255, 255, .88);
  backdrop-filter: saturate(180%) blur(12px);
  border-bottom: 1px solid var(--line);
  display: flex; align-items: center; gap: 14px;
  padding: 0 22px; position: sticky; top: 0; z-index: 20;
}
.page-title { font-size: 16px; font-weight: 700; }
.page-sub { font-size: 12px; color: var(--text-3); }
.topbar-right { margin-left: auto; display: flex; align-items: center; gap: 10px; }
.content { padding: 20px 22px 40px; flex: 1; }

/* ------------------------------- 卡片 ------------------------------- */
.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
}
.card-h { padding: 15px 18px; border-bottom: 1px solid var(--line-2); display: flex; align-items: center; gap: 10px; }
.card-h h3 { margin: 0; font-size: 14.5px; font-weight: 700; }
.card-h .sub { font-size: 12px; color: var(--text-3); }
.card-h .right { margin-left: auto; display: flex; gap: 8px; align-items: center; }
.card-b { padding: 18px; }
.card-b.tight { padding: 0; }

.grid { display: grid; gap: 16px; }
.g2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.g3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.g4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.g5 { grid-template-columns: repeat(5, minmax(0, 1fr)); }
@media (max-width: 1180px) { .g4, .g5 { grid-template-columns: repeat(2, minmax(0, 1fr)); } .g3 { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 760px) { .grid[class*=g] { grid-template-columns: 1fr; } }

/* 统计卡 */
.stat { padding: 16px 18px; border-radius: var(--radius-lg); background: #fff; border: 1px solid var(--line); position: relative; overflow: hidden; }
.stat::after { content: ''; position: absolute; right: -20px; top: -20px; width: 78px; height: 78px; border-radius: 50%; background: var(--grad-soft); }
.stat .k { font-size: 12.5px; color: var(--text-2); display: flex; align-items: center; gap: 6px; position: relative; }
.stat .v { font-size: 26px; font-weight: 800; letter-spacing: -.5px; margin-top: 6px; position: relative; font-variant-numeric: tabular-nums; }
.stat .v small { font-size: 13px; font-weight: 600; color: var(--text-3); margin-left: 3px; }
.stat .d { font-size: 12px; color: var(--text-3); margin-top: 4px; position: relative; }
.stat.hl { background: var(--grad); border: none; color: #fff; }
.stat.hl .k, .stat.hl .d { color: rgba(255, 255, 255, .85); }
.stat.hl .v small { color: rgba(255, 255, 255, .75); }
.stat.hl::after { background: rgba(255, 255, 255, .13); }

/* ------------------------------- 按钮 ------------------------------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 8px 15px; border-radius: 9px; border: 1px solid var(--line);
  background: #fff; color: var(--text-2); font-size: 13px; font-weight: 600;
  cursor: pointer; transition: .16s; font-family: inherit; white-space: nowrap;
}
.btn:hover { border-color: #cfd8e8; background: var(--surface-2); color: var(--text); }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn-pri { background: var(--grad); border: none; color: #fff; box-shadow: 0 3px 10px rgba(37, 99, 235, .28); }
.btn-pri:hover { background: var(--grad); filter: brightness(1.06); color: #fff; }
.btn-ghost { border-color: transparent; background: transparent; }
.btn-ghost:hover { background: var(--surface-2); }
.btn-sm { padding: 5px 11px; font-size: 12.5px; border-radius: 8px; }
.btn-xs { padding: 3px 8px; font-size: 12px; border-radius: 7px; }
.btn-danger { color: var(--danger); border-color: #fecdca; background: var(--danger-bg); }
.btn-danger:hover { background: #fee4e2; color: var(--danger); border-color: #fda29b; }
.btn-block { width: 100%; }

/* ------------------------------- 表单 ------------------------------- */
.field { margin-bottom: 15px; }
.field > label { display: block; font-size: 12.5px; font-weight: 600; color: var(--text-2); margin-bottom: 6px; }
.field .hint { font-size: 11.5px; color: var(--text-3); margin-top: 5px; }
input, select, textarea {
  width: 100%; padding: 9px 12px; border: 1px solid var(--line);
  border-radius: 9px; font-size: 13.5px; font-family: inherit; color: var(--text);
  background: #fff; transition: .16s; outline: none;
}
input:focus, select:focus, textarea:focus { border-color: var(--pri); box-shadow: 0 0 0 3px rgba(37, 99, 235, .12); }
input::placeholder, textarea::placeholder { color: var(--text-3); }
textarea { resize: vertical; min-height: 84px; line-height: 1.65; }
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 24 24' fill='none' stroke='%2398a2b3' stroke-width='2.5'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 11px center; padding-right: 32px; }
.row { display: flex; gap: 12px; }
.row > * { flex: 1; min-width: 0; }
.row-3 > * { flex: 1 1 33%; }
.switch { position: relative; width: 38px; height: 21px; border-radius: 20px; background: #d8dee9; cursor: pointer; transition: .2s; flex: 0 0 38px; }
.switch.on { background: var(--grad); }
.switch::after { content: ''; position: absolute; width: 17px; height: 17px; border-radius: 50%; background: #fff; top: 2px; left: 2px; transition: .2s; box-shadow: 0 1px 3px rgba(0,0,0,.2); }
.switch.on::after { left: 19px; }
.check { display: flex; align-items: center; gap: 7px; font-size: 13px; color: var(--text-2); cursor: pointer; }
.check input { width: 15px; height: 15px; accent-color: var(--pri); }

/* ------------------------------- 表格 ------------------------------- */
.tbl-wrap { overflow-x: auto; }
table.tbl { width: 100%; border-collapse: collapse; font-size: 13px; }
table.tbl th {
  text-align: left; padding: 11px 14px; background: var(--surface-2);
  color: var(--text-2); font-weight: 600; font-size: 12.5px;
  border-bottom: 1px solid var(--line); white-space: nowrap;
}
table.tbl td { padding: 12px 14px; border-bottom: 1px solid var(--line-2); vertical-align: middle; }
table.tbl tbody tr:hover { background: #fbfcfe; }
table.tbl tbody tr:last-child td { border-bottom: none; }
table.tbl .num { font-variant-numeric: tabular-nums; font-weight: 600; }
.t-right { text-align: right; }
.t-center { text-align: center; }
.nowrap { white-space: nowrap; }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 12.5px; }

/* ------------------------------- 徽章 ------------------------------- */
.badge { display: inline-flex; align-items: center; gap: 4px; padding: 2px 9px; border-radius: 20px; font-size: 11.5px; font-weight: 600; line-height: 18px; white-space: nowrap; }
.badge::before { content: ''; width: 5px; height: 5px; border-radius: 50%; background: currentColor; }
.badge.nodot::before { display: none; }
.b-ok { background: var(--ok-bg); color: #027a48; }
.b-warn { background: var(--warn-bg); color: #b54708; }
.b-danger { background: var(--danger-bg); color: #b42318; }
.b-info { background: var(--info-bg); color: #1849a9; }
.b-gray { background: #f2f4f7; color: #475467; }
.b-purple { background: #f4f3ff; color: #5925dc; }
.tag { display: inline-block; padding: 1px 8px; border-radius: 6px; background: var(--surface-2); border: 1px solid var(--line); font-size: 11.5px; color: var(--text-2); margin: 0 4px 4px 0; }

/* ------------------------------- 模态框 ------------------------------- */
.mask {
  position: fixed; inset: 0; background: rgba(16, 24, 40, .45);
  backdrop-filter: blur(2px); z-index: 100;
  display: flex; align-items: center; justify-content: center; padding: 20px;
  opacity: 0; pointer-events: none; transition: .18s;
}
.mask.show { opacity: 1; pointer-events: auto; }
.modal {
  background: #fff; border-radius: var(--radius-lg); width: 100%; max-width: 560px;
  max-height: 88vh; display: flex; flex-direction: column;
  box-shadow: var(--shadow-lg); transform: translateY(10px) scale(.98); transition: .18s;
}
.mask.show .modal { transform: none; }
.modal.wide { max-width: 860px; }
.modal-h { padding: 16px 20px; border-bottom: 1px solid var(--line-2); display: flex; align-items: center; }
.modal-h h3 { margin: 0; font-size: 15.5px; font-weight: 700; }
.modal-h .x { margin-left: auto; cursor: pointer; color: var(--text-3); font-size: 20px; line-height: 1; padding: 0 4px; }
.modal-h .x:hover { color: var(--text); }
.modal-b { padding: 20px; overflow-y: auto; flex: 1; }
.modal-f { padding: 14px 20px; border-top: 1px solid var(--line-2); display: flex; gap: 10px; justify-content: flex-end; }

/* ------------------------------- Toast ------------------------------- */
#toasts { position: fixed; top: 18px; right: 18px; z-index: 200; display: flex; flex-direction: column; gap: 10px; }
.toast {
  background: #fff; border: 1px solid var(--line); border-left: 3px solid var(--pri);
  border-radius: 10px; padding: 11px 16px; box-shadow: var(--shadow-lg);
  font-size: 13.5px; font-weight: 500; min-width: 220px; max-width: 380px;
  animation: slideIn .22s ease;
}
.toast.ok { border-left-color: var(--ok); }
.toast.err { border-left-color: var(--danger); }
.toast.warn { border-left-color: var(--warn); }
@keyframes slideIn { from { transform: translateX(24px); opacity: 0; } to { transform: none; opacity: 1; } }

/* ------------------------------- Tabs ------------------------------- */
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin-bottom: 18px; overflow-x: auto; }
.tab { padding: 9px 15px; font-size: 13.5px; font-weight: 600; color: var(--text-2); cursor: pointer; border-bottom: 2px solid transparent; margin-bottom: -1px; white-space: nowrap; transition: .16s; }
.tab:hover { color: var(--text); }
.tab.active { color: var(--pri); border-bottom-color: var(--pri); }
.pill-group { display: inline-flex; background: var(--surface-2); border: 1px solid var(--line); border-radius: 9px; padding: 3px; gap: 2px; }
.pill { padding: 5px 13px; border-radius: 7px; font-size: 12.5px; font-weight: 600; color: var(--text-2); cursor: pointer; transition: .16s; white-space: nowrap; }
.pill.active { background: #fff; color: var(--pri); box-shadow: var(--shadow-sm); }

/* ------------------------------- 其他 ------------------------------- */
.empty { padding: 60px 20px; text-align: center; color: var(--text-3); }
.empty .ei { font-size: 40px; opacity: .35; margin-bottom: 10px; }
.empty p { margin: 4px 0; font-size: 13.5px; }
.toolbar { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin-bottom: 16px; }
.toolbar .grow { flex: 1; min-width: 180px; }
.search { position: relative; }
.search svg { position: absolute; left: 11px; top: 50%; transform: translateY(-50%); width: 15px; height: 15px; color: var(--text-3); }
.search input { padding-left: 34px; }

.bar { height: 6px; border-radius: 6px; background: var(--line-2); overflow: hidden; }
.bar > i { display: block; height: 100%; background: var(--grad); border-radius: 6px; transition: width .5s; }

.chart { width: 100%; height: 260px; display: block; }
.legend { display: flex; gap: 16px; flex-wrap: wrap; font-size: 12.5px; color: var(--text-2); }
.legend i { display: inline-block; width: 9px; height: 9px; border-radius: 3px; margin-right: 6px; }

.kv { display: flex; justify-content: space-between; padding: 9px 0; border-bottom: 1px dashed var(--line-2); font-size: 13px; }
.kv:last-child { border-bottom: none; }
.kv .k { color: var(--text-2); }
.kv .v { font-weight: 600; font-variant-numeric: tabular-nums; }

/* 账号树 */
.tree { font-size: 13.5px; }
.tree-node { border-left: 2px solid var(--line); margin-left: 10px; padding-left: 14px; }
.tree-row { display: flex; align-items: center; gap: 9px; padding: 8px 10px; border-radius: 9px; cursor: default; }
.tree-row:hover { background: var(--surface-2); }
.tree-row .nm { font-weight: 600; }
.tree-toggle { width: 16px; height: 16px; display: grid; place-items: center; cursor: pointer; color: var(--text-3); font-size: 10px; transition: .16s; }
.tree-toggle.open { transform: rotate(90deg); }

/* 落地页编辑器 */
.builder { display: grid; grid-template-columns: 240px 1fr 260px; gap: 16px; }
@media (max-width: 1100px) { .builder { grid-template-columns: 1fr; } }
.block-palette { display: flex; flex-direction: column; gap: 8px; }
.block-item { display: flex; align-items: center; gap: 9px; padding: 10px 12px; border: 1px dashed var(--line); border-radius: 10px; cursor: pointer; font-size: 13px; font-weight: 500; color: var(--text-2); transition: .16s; background: #fff; }
.block-item:hover { border-color: var(--pri); color: var(--pri); background: var(--info-bg); }
.block-list { display: flex; flex-direction: column; gap: 10px; }
.blk { border: 1px solid var(--line); border-radius: 12px; padding: 13px 15px; background: #fff; position: relative; }
.blk.sel { border-color: var(--pri); box-shadow: 0 0 0 3px rgba(37, 99, 235, .1); }
.blk-h { display: flex; align-items: center; gap: 8px; font-size: 12px; font-weight: 700; color: var(--text-3); text-transform: uppercase; letter-spacing: .5px; margin-bottom: 9px; }
.blk-h .ops { margin-left: auto; display: flex; gap: 4px; }
.blk-h .op { cursor: pointer; color: var(--text-3); font-size: 12px; padding: 1px 6px; border-radius: 5px; }
.blk-h .op:hover { background: var(--surface-2); color: var(--text); }

/* 手机预览 */
.phone { width: 100%; max-width: 300px; margin: 0 auto; border: 9px solid #1b1f2a; border-radius: 34px; overflow: hidden; background: #fff; box-shadow: var(--shadow-lg); }
.phone-top { height: 26px; background: #1b1f2a; display: flex; align-items: center; justify-content: center; }
.phone-top i { width: 62px; height: 5px; border-radius: 5px; background: #3a4152; display: block; }
.phone-body { height: 520px; overflow-y: auto; background: #fff; }

/* 名片/落地页渲染 */
.lp-hero { background: var(--grad); color: #fff; padding: 46px 24px; text-align: center; }
.lp-hero h1 { margin: 0 0 10px; font-size: 26px; font-weight: 800; letter-spacing: -.4px; }
.lp-hero p { margin: 0 0 20px; opacity: .92; font-size: 14.5px; }
.lp-btn { display: inline-block; padding: 12px 34px; border-radius: 30px; background: #fff; color: var(--pri); font-weight: 700; font-size: 14.5px; border: none; cursor: pointer; box-shadow: 0 6px 20px rgba(0, 0, 0, .16); }
.lp-sec { padding: 26px 24px; }
.lp-sec h2 { font-size: 18px; margin: 0 0 12px; }
.lp-sec p { color: var(--text-2); font-size: 14px; margin: 0 0 10px; }
.lp-img { width: 100%; border-radius: 14px; display: block; }
.lp-form { background: #fff; border-radius: 16px; padding: 20px; box-shadow: var(--shadow); }
.lp-wrap { max-width: 640px; margin: 0 auto; background: #fff; min-height: 100vh; }

/* 登录页 */
.login-page { min-height: 100vh; display: grid; grid-template-columns: 1.15fr 1fr; }
@media (max-width: 900px) { .login-page { grid-template-columns: 1fr; } .login-art { display: none !important; } }
.login-art { background: var(--grad); color: #fff; padding: 56px; display: flex; flex-direction: column; justify-content: center; position: relative; overflow: hidden; }
.login-art::before { content: ''; position: absolute; width: 460px; height: 460px; border-radius: 50%; background: rgba(255, 255, 255, .09); top: -140px; right: -140px; }
.login-art::after { content: ''; position: absolute; width: 320px; height: 320px; border-radius: 50%; background: rgba(255, 255, 255, .07); bottom: -110px; left: -80px; }
.login-art > * { position: relative; z-index: 1; }
.login-art h1 { font-size: 34px; font-weight: 800; margin: 0 0 14px; letter-spacing: -.6px; line-height: 1.25; }
.login-art p { font-size: 15px; opacity: .9; margin: 0 0 30px; max-width: 420px; line-height: 1.75; }
.feat { display: flex; gap: 12px; align-items: flex-start; margin-bottom: 15px; }
.feat .fi { width: 34px; height: 34px; border-radius: 10px; background: rgba(255, 255, 255, .18); display: grid; place-items: center; flex: 0 0 34px; font-size: 16px; }
.feat .ft { font-size: 14px; font-weight: 600; }
.feat .fs { font-size: 12.5px; opacity: .82; }
.login-form { display: flex; align-items: center; justify-content: center; padding: 40px 28px; background: #fff; }
.login-box { width: 100%; max-width: 372px; }
.login-box h2 { font-size: 23px; font-weight: 800; margin: 0 0 6px; }
.login-box .sub { color: var(--text-3); font-size: 13.5px; margin-bottom: 26px; }
.demo-acc { display: grid; gap: 8px; margin-top: 22px; }
.demo-btn { display: flex; align-items: center; gap: 10px; padding: 9px 12px; border: 1px solid var(--line); border-radius: 10px; cursor: pointer; background: var(--surface-2); transition: .16s; text-align: left; font-family: inherit; width: 100%; }
.demo-btn:hover { border-color: var(--pri); background: var(--info-bg); }
.demo-btn .dn { font-size: 12.5px; font-weight: 700; color: var(--text); }
.demo-btn .dd { font-size: 11.5px; color: var(--text-3); }
.demo-btn .dr { margin-left: auto; font-size: 11px; color: var(--pri); font-weight: 600; }
.divider { display: flex; align-items: center; gap: 10px; color: var(--text-3); font-size: 12px; margin: 22px 0 12px; }
.divider::before, .divider::after { content: ''; flex: 1; height: 1px; background: var(--line); }

/* 移动端 */
@media (max-width: 860px) {
  .sidebar { transform: translateX(-100%); transition: .22s; }
  .sidebar.open { transform: none; box-shadow: var(--shadow-lg); }
  .main { margin-left: 0; }
  .menu-btn { display: inline-flex !important; }
  .content { padding: 14px; }
}
.menu-btn { display: none; cursor: pointer; color: var(--text-2); }
.skeleton { background: linear-gradient(90deg, #f2f4f7 25%, #e9edf3 50%, #f2f4f7 75%); background-size: 200% 100%; animation: sk 1.3s infinite; border-radius: 8px; }
@keyframes sk { to { background-position: -200% 0; } }
