:root {
  --bg: #f5f7fa;
  --panel: #ffffff;
  --border: #e4e8ee;
  --text: #1f2329;
  --muted: #6b7280;
  --primary: #1a73e8;
  --primary-soft: #e8f0fe;
  --green: #0d904f;
  --green-soft: #e6f4ea;
  --red: #d93025;
  --red-soft: #fce8e6;
  --orange: #e37400;
  --orange-soft: #fff4e5;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(16, 24, 40, .04), 0 1px 3px rgba(16, 24, 40, .06);
}

* { margin: 0; padding: 0; box-sizing: border-box; }

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

/* ============ 登录 / 注册 ============ */
#auth {
  position: fixed; inset: 0; display: flex; align-items: center; justify-content: center;
  background: radial-gradient(900px 420px at 80% -10%, #e8f1ff 0%, rgba(232,241,255,0) 60%), #f7f9fc;
  padding: 20px; overflow: auto;
}
#auth .box {
  width: 392px; max-width: 100%; background: var(--panel); border-radius: 16px; padding: 30px;
  box-shadow: 0 18px 50px rgba(16, 24, 40, .12); border: 1px solid rgba(228, 232, 238, .8);
}
.auth-brand { display: flex; align-items: center; gap: 10px; margin-bottom: 22px; }
.auth-brand i {
  width: 36px; height: 36px; border-radius: 10px; background: linear-gradient(135deg, #1a73e8, #4f9bff);
  color: #fff; display: grid; place-items: center; font-style: normal; font-weight: 800; font-size: 17px;
}
.auth-brand b { font-size: 16px; display: block; letter-spacing: .2px; }
.auth-brand small { color: var(--muted); font-size: 12px; }

.tabs { display: flex; gap: 4px; background: #f1f3f7; border-radius: 9px; padding: 3px; margin-bottom: 20px; }
.tab { flex: 1; text-align: center; padding: 7px 0; font-size: 13.5px; border-radius: 7px; cursor: pointer; color: var(--muted); }
.tab.active { background: #fff; color: var(--text); font-weight: 600; box-shadow: var(--shadow); }
.auth-hint { color: var(--muted); font-size: 11.5px; line-height: 1.7; margin-top: 14px; text-align: center; }
#auth .err { color: var(--red); font-size: 13px; min-height: 20px; margin-top: 8px; }

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

.sidebar {
  width: 212px; flex-shrink: 0; background: var(--panel); border-right: 1px solid var(--border);
  position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column; padding: 18px 12px;
}
.brand { display: flex; align-items: center; gap: 9px; padding: 4px 10px 18px; }
.brand .logo {
  width: 30px; height: 30px; border-radius: 8px; background: var(--primary); color: #fff;
  display: grid; place-items: center; font-weight: 700; font-size: 15px;
}
.brand b { font-size: 15px; letter-spacing: .2px; }
.brand small { display: block; color: var(--muted); font-size: 11px; font-weight: 400; }

.nav-item {
  display: flex; align-items: center; gap: 10px; padding: 9px 12px; border-radius: 8px;
  color: #374151; cursor: pointer; font-size: 13.5px; margin-bottom: 2px; user-select: none;
}
.nav-item:hover { background: #f3f5f9; }
.nav-item.active { background: var(--primary-soft); color: var(--primary); font-weight: 600; }
.nav-item .ic { width: 16px; text-align: center; opacity: .85; }
.sidebar .foot { margin-top: auto; padding: 10px; font-size: 11px; color: var(--muted); }
.sidebar .foot span { display: block; }
.dot { display: inline-block; width: 7px; height: 7px; border-radius: 50%; background: var(--green); margin-right: 5px; }
.dot.off { background: #c9ced6; }

.mainwrap { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar {
  height: 62px; flex-shrink: 0; background: rgba(255, 255, 255, .92); backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--border); display: flex; align-items: center; justify-content: space-between;
  padding: 0 26px; gap: 16px; position: sticky; top: 0; z-index: 20;
}
.tb-tenant { font-size: 14.5px; font-weight: 650; display: flex; align-items: center; gap: 8px; }
.tb-sub { font-size: 12px; color: var(--muted); margin-top: 1px; }
.tb-right { display: flex; align-items: center; gap: 14px; }
.usermenu { display: flex; align-items: center; gap: 9px; }
.avatar {
  width: 32px; height: 32px; border-radius: 50%; background: #e8f0fe; color: #12509e;
  display: grid; place-items: center; font-weight: 700; font-size: 13px;
}
.uinfo { line-height: 1.25; }
.uinfo b { font-size: 13px; display: block; }
.uinfo small { color: var(--muted); font-size: 11px; }

.main { flex: 1; min-width: 0; padding: 22px 26px 40px; }
.page-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 18px; gap: 12px; }
.page-head h2 { font-size: 19px; font-weight: 650; }
.page-head .sub { color: var(--muted); font-size: 12.5px; margin-top: 2px; }

/* ============ 通用组件 ============ */
.card {
  background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 18px; margin-bottom: 16px;
}
.card h3 { font-size: 14.5px; font-weight: 650; margin-bottom: 12px; display: flex; justify-content: space-between; align-items: center; }
.card h3 .hint { font-weight: 400; color: var(--muted); font-size: 12px; }

.grid { display: grid; gap: 14px; }
.grid.c4 { grid-template-columns: repeat(4, 1fr); }
.grid.c3 { grid-template-columns: repeat(3, 1fr); }
.grid.c2 { grid-template-columns: repeat(2, 1fr); }

.kpi { background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px 18px; box-shadow: var(--shadow); }
.kpi .label { color: var(--muted); font-size: 12.5px; }
.kpi .num { font-size: 26px; font-weight: 700; margin-top: 6px; letter-spacing: -.5px; }
.kpi .delta { font-size: 12px; color: var(--muted); margin-top: 2px; }
.kpi.hl .num { color: var(--primary); }

button {
  font: inherit; cursor: pointer; border: 1px solid var(--border); background: var(--panel);
  color: var(--text); padding: 7px 14px; border-radius: 7px; transition: .15s;
}
button:hover { background: #f6f8fb; }
button.primary { background: var(--primary); border-color: var(--primary); color: #fff; }
button.primary:hover { background: #1668d3; }
button.danger { color: var(--red); border-color: #f3c7c3; background: #fff; }
button.danger:hover { background: var(--red-soft); }
button.sm { padding: 4px 10px; font-size: 12.5px; border-radius: 6px; }
button:disabled { opacity: .5; cursor: not-allowed; }

input, select, textarea {
  font: inherit; padding: 7px 10px; border: 1px solid var(--border); border-radius: 7px;
  background: #fff; color: var(--text); width: 100%; outline: none;
}
input:focus, select:focus, textarea:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(26, 115, 232, .12); }
textarea { resize: vertical; min-height: 70px; font-family: inherit; }
label.field { display: block; margin-bottom: 12px; }
label.field > span { display: block; font-size: 12.5px; color: var(--muted); margin-bottom: 5px; }

table { width: 100%; border-collapse: collapse; font-size: 13px; }
th { text-align: left; color: var(--muted); font-weight: 500; font-size: 12px; padding: 8px 10px; border-bottom: 1px solid var(--border); white-space: nowrap; }
td { padding: 10px; border-bottom: 1px solid #f1f3f7; vertical-align: top; }
tbody tr:hover { background: #fafbfd; }
td .mono { font-family: ui-monospace, Consolas, monospace; font-size: 12px; color: var(--muted); }

.badge { display: inline-block; padding: 1px 8px; border-radius: 20px; font-size: 11.5px; font-weight: 500; white-space: nowrap; }
.b-blue { background: var(--primary-soft); color: #12509e; }
.b-green { background: var(--green-soft); color: #0b6b3d; }
.b-red { background: var(--red-soft); color: #a5231b; }
.b-orange { background: var(--orange-soft); color: #a35400; }
.b-gray { background: #eef0f4; color: #5b6270; }

.bar { height: 8px; border-radius: 20px; background: #eef0f4; overflow: hidden; }
.bar > i { display: block; height: 100%; background: var(--primary); border-radius: 20px; }

.empty { text-align: center; color: var(--muted); padding: 40px 0; font-size: 13px; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.spacer { flex: 1; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.nowrap { white-space: nowrap; }

/* 用量小卡 */
.qbox { border: 1px solid #eef1f6; border-radius: 8px; padding: 12px 14px; background: #fcfdff; }

/* 提示条 */
.notice {
  background: #f5f9ff; border: 1px solid #dbe8fb; color: #2d4a75;
  border-radius: 8px; padding: 10px 12px; font-size: 12.5px; margin-bottom: 14px; line-height: 1.7;
}
.notice.warn { background: #fff8ec; border-color: #f3e0bf; color: #8a5a00; }

/* 绑定码 */
.codebox { text-align: center; border: 1px dashed #cfd9e8; border-radius: 12px; padding: 20px; background: #fbfdff; }
.codebox.ok { border-style: solid; border-color: #bfe3cd; background: #f6fcf8; }
.codebox .code { display: flex; gap: 7px; justify-content: center; margin: 10px 0; }
.codebox .code span {
  width: 44px; height: 54px; display: grid; place-items: center; font-size: 26px; font-weight: 700;
  background: #fff; border: 1px solid #dfe6ef; border-radius: 9px; box-shadow: var(--shadow); letter-spacing: -1px;
}
.codebox .big-ok { font-size: 30px; color: var(--green); line-height: 1; margin-bottom: 6px; }

.steps-list { margin: 0; padding-left: 18px; color: #475467; font-size: 12.8px; line-height: 1.9; }
.steps-list li { margin-bottom: 3px; }

/* 设备接入码 */
.card.access { display: flex; justify-content: space-between; align-items: center; gap: 16px; flex-wrap: wrap; }
.card.access .key {
  font-family: ui-monospace, Consolas, monospace; font-size: 14px; letter-spacing: .6px;
  background: #f5f7fb; border: 1px dashed #d7dde8; border-radius: 8px; padding: 7px 12px;
}

/* 套餐 */
.pricing { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; }
.plan { border: 1px solid var(--border); border-radius: 12px; padding: 18px; background: #fff; position: relative; display: flex; flex-direction: column; }
.plan.hot { border-color: var(--primary); box-shadow: 0 12px 30px rgba(26, 115, 232, .1); }
.plan.current { background: #fbfdff; }
.plan .flag { position: absolute; top: -10px; left: 16px; background: var(--primary); color: #fff; font-size: 10.5px; font-weight: 700; padding: 1px 8px; border-radius: 20px; }
.plan h3 { font-size: 13.5px; margin: 0; color: var(--text); }
.plan .price { font-size: 24px; font-weight: 800; letter-spacing: -.6px; margin: 6px 0 4px; }
.plan .price small { font-size: 12px; font-weight: 500; color: var(--muted); letter-spacing: 0; }
.plan ul { list-style: none; margin: 12px 0 16px; display: grid; gap: 6px; }
.plan li { font-size: 12.3px; color: #475467; padding-left: 16px; position: relative; }
.plan li:before { content: "✓"; position: absolute; left: 0; color: var(--green); font-weight: 700; font-size: 11px; }
.plan .btn { margin-top: auto; width: 100%; background: #fff; border: 1px solid var(--border); color: var(--text); padding: 7px 0; border-radius: 7px; font-size: 13px; }
.plan .btn.primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.plan .btn:disabled { background: #f4f6fa; color: var(--muted); }

/* 权限说明 */
.perm { list-style: none; display: grid; gap: 10px; }
.perm li { font-size: 12.8px; color: #475467; padding-left: 12px; border-left: 2px solid #e6ebf4; line-height: 1.7; }
.perm b { color: var(--text); }

/* 弹窗 */
.mask { position: fixed; inset: 0; background: rgba(16, 24, 40, .45); display: none; align-items: center; justify-content: center; z-index: 100; padding: 20px; }
.mask.show { display: flex; }
.modal { background: var(--panel); border-radius: 12px; width: 580px; max-width: 100%; max-height: 88vh; overflow: auto; box-shadow: 0 20px 50px rgba(16, 24, 40, .2); }
.modal header { padding: 16px 20px; border-bottom: 1px solid var(--border); font-weight: 650; display: flex; justify-content: space-between; align-items: center; }
.modal .body { padding: 18px 20px; }
.modal footer { padding: 14px 20px; border-top: 1px solid var(--border); display: flex; justify-content: flex-end; gap: 10px; }
.x { cursor: pointer; color: var(--muted); font-size: 18px; line-height: 1; }

.toast {
  position: fixed; right: 22px; bottom: 22px; background: #1f2329; color: #fff; padding: 10px 16px;
  border-radius: 8px; font-size: 13px; opacity: 0; transform: translateY(8px); transition: .2s; z-index: 200;
  max-width: 380px;
}
.toast.show { opacity: 1; transform: translateY(0); }
.toast.err { background: var(--red); }

.tag { display: inline-block; padding: 1px 7px; border-radius: 5px; background: #f1f3f7; font-size: 11.5px; color: #4b5261; margin: 1px 2px 1px 0; }

@media (max-width: 1180px) {
  .pricing { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 1080px) {
  .grid.c4 { grid-template-columns: repeat(2, 1fr); }
  .grid.c3, .grid.c2 { grid-template-columns: 1fr; }
  .topbar { padding: 0 16px; }
  .main { padding: 18px 16px 30px; }
  .tb-sub { display: none; }
}
@media (max-width: 820px) {
  .sidebar { display: none; }
  .pricing { grid-template-columns: 1fr; }
}

/* 阶段切换 pills（线索 CRM 页：CRM 线索 / 已私信 / 已触达 / 全部） */
.pills { display: flex; gap: 6px; flex-wrap: wrap; }
.pill {
  padding: 4px 11px; border-radius: 99px; border: 1px solid var(--border);
  font-size: 12.5px; cursor: pointer; background: #fff; color: #4a5262;
}
.pill.active { background: var(--primary); border-color: var(--primary); color: #fff; }
