/* ==================== 基础重置 ==================== */
* { margin: 0; padding: 0; box-sizing: border-box; }
:root {
  --bg: #1a1d24;
  --bg-2: #21252e;
  --bg-3: #2a2f3a;
  --border: #363c48;
  --text: #e4e7ee;
  --text-dim: #9aa3b2;
  --primary: #4f7cff;
  --primary-hover: #3d6bf5;
  --success: #34c77b;
  --warning: #e8a33d;
  --danger: #e05656;
  --radius: 10px;
}
html, body { height: 100%; }
body {
  font-family: "PingFang SC", "Microsoft YaHei", -apple-system, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
}
.hidden { display: none !important; }

/* ==================== 按钮 ==================== */
.btn {
  border: none; border-radius: 8px; cursor: pointer;
  padding: 9px 18px; font-size: 14px;
  transition: all .15s; font-family: inherit;
}
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-hover); }
.btn-ghost { background: transparent; color: var(--text-dim); border: 1px solid var(--border); }
.btn-ghost:hover { color: var(--text); border-color: var(--text-dim); }
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover { filter: brightness(1.1); }
.btn-success { background: var(--success); color: #fff; }
.btn-sm { padding: 6px 12px; font-size: 13px; }
.btn-block { width: 100%; }
.btn:disabled { opacity: .5; cursor: not-allowed; }

/* ==================== 登录页 ==================== */
.login-screen {
  min-height: 100vh; display: flex;
  align-items: center; justify-content: center;
  background: linear-gradient(135deg, #171a21 0%, #1e2430 100%);
  padding: 20px;
}
.login-card {
  width: 380px; background: var(--bg-2);
  border: 1px solid var(--border); border-radius: 16px;
  padding: 40px 36px; text-align: center;
}
.login-logo {
  width: 64px; height: 64px; margin: 0 auto 16px;
  background: linear-gradient(135deg, var(--primary), #7a5cff);
  border-radius: 16px; display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 24px; color: #fff;
}
.login-card h1 { font-size: 22px; margin-bottom: 6px; }
.login-sub { color: var(--text-dim); font-size: 13px; margin-bottom: 28px; }
.form-group { text-align: left; margin-bottom: 18px; }
.form-group label {
  display: block; font-size: 13px; color: var(--text-dim); margin-bottom: 6px;
}
.form-group input, .form-group select, .form-group textarea {
  width: 100%; padding: 10px 12px;
  background: var(--bg-3); border: 1px solid var(--border);
  border-radius: 8px; color: var(--text); font-size: 14px; font-family: inherit;
  outline: none; transition: border .15s;
}
.form-group input:focus, .form-group select:focus, .form-group textarea:focus {
  border-color: var(--primary);
}
.login-error {
  background: rgba(224,86,86,.12); color: var(--danger);
  border: 1px solid rgba(224,86,86,.3); border-radius: 8px;
  padding: 8px 12px; font-size: 13px; margin-bottom: 14px;
}
.login-tip { margin-top: 18px; font-size: 12px; color: var(--text-dim); }

/* ==================== 应用布局 ==================== */
.app { display: flex; height: 100vh; overflow: hidden; }
.sidebar {
  width: 220px; background: var(--bg-2);
  border-right: 1px solid var(--border);
  display: flex; flex-direction: column; flex-shrink: 0;
}
.sidebar-brand {
  padding: 20px; font-size: 18px; font-weight: 700;
  display: flex; align-items: center; gap: 10px;
  border-bottom: 1px solid var(--border);
}
.brand-dot {
  width: 32px; height: 32px; border-radius: 8px;
  background: linear-gradient(135deg, var(--primary), #7a5cff);
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 13px; color: #fff;
}
.sidebar-nav { flex: 1; padding: 12px; display: flex; flex-direction: column; gap: 4px; }
.nav-item {
  display: flex; align-items: center; gap: 10px;
  padding: 11px 14px; border-radius: 8px;
  color: var(--text-dim); cursor: pointer; transition: all .15s;
  font-size: 14px; user-select: none;
}
.nav-item:hover { color: var(--text); background: var(--bg-3); }
.nav-item.active { color: #fff; background: var(--primary); }
.nav-ico { font-size: 16px; width: 20px; text-align: center; }
.sidebar-footer {
  padding: 16px; border-top: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
}
.user-chip { display: flex; align-items: center; gap: 8px; font-size: 13px; }
.avatar {
  width: 30px; height: 30px; border-radius: 50%;
  background: var(--primary); color: #fff;
  display: inline-flex; align-items: center; justify-content: center; font-size: 13px;
}

/* ==================== 主区域 ==================== */
.main { flex: 1; display: flex; flex-direction: column; overflow: hidden; }
.topbar {
  height: 60px; display: flex; align-items: center; justify-content: space-between;
  padding: 0 24px; border-bottom: 1px solid var(--border); background: var(--bg-2);
  flex-shrink: 0;
}
.topbar h2 { font-size: 17px; font-weight: 600; }
.topbar-actions { display: flex; gap: 10px; }
.content { flex: 1; overflow-y: auto; padding: 24px; }

/* ==================== 卡片 / 网格 ==================== */
.grid { display: grid; gap: 16px; }
.grid-4 { grid-template-columns: repeat(4, 1fr); }
.grid-2 { grid-template-columns: repeat(2, 1fr); }
.card {
  background: var(--bg-2); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 20px;
}
.stat-value { font-size: 28px; font-weight: 700; margin: 6px 0 2px; }
.stat-label { color: var(--text-dim); font-size: 13px; }
.stat-sub { font-size: 12px; color: var(--text-dim); margin-top: 4px; }

/* ==================== 表格 ==================== */
.table-wrap { background: var(--bg-2); border: 1px solid var(--border); border-radius: var(--radius); overflow: auto; }
table { width: 100%; border-collapse: collapse; min-width: 900px; }
th, td { padding: 12px 16px; text-align: left; font-size: 13px; }
thead th {
  background: var(--bg-3); color: var(--text-dim);
  font-weight: 500; border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
tbody tr { border-bottom: 1px solid var(--border); }
tbody tr:hover { background: rgba(79,124,255,.06); }
tbody tr:last-child { border-bottom: none; }

/* ==================== 标签 ==================== */
.tag {
  display: inline-block; padding: 3px 10px; border-radius: 20px;
  font-size: 12px; white-space: nowrap;
}
.tag-blue { background: rgba(79,124,255,.15); color: #7ba0ff; }
.tag-green { background: rgba(52,199,123,.15); color: #52d98c; }
.tag-orange { background: rgba(232,163,61,.15); color: #f0b45e; }
.tag-red { background: rgba(224,86,86,.15); color: #ef8080; }
.tag-gray { background: rgba(154,163,178,.15); color: var(--text-dim); }
.tag-purple { background: rgba(158,110,255,.15); color: #b28aff; }
.tag-teal { background: rgba(38,190,180,.15); color: #5fd8cf; }
.tag-yellow { background: rgba(230,211,80,.18); color: #e0d060; }

/* ==================== 管道看板 ==================== */
.pipeline-board { display: flex; gap: 16px; overflow-x: auto; padding-bottom: 12px; }
.pipeline-col {
  min-width: 260px; flex: 1; background: var(--bg-2);
  border: 1px solid var(--border); border-radius: var(--radius);
  display: flex; flex-direction: column; max-height: calc(100vh - 160px);
}
.pipeline-col-header {
  padding: 14px 16px; border-bottom: 1px solid var(--border);
  display: flex; justify-content: space-between; align-items: center;
  font-weight: 600; font-size: 14px;
}
.pipeline-col-body { padding: 12px; display: flex; flex-direction: column; gap: 10px; overflow-y: auto; }
.deal-card {
  background: var(--bg-3); border: 1px solid var(--border);
  border-radius: 8px; padding: 12px; cursor: pointer; transition: border .15s;
}
.deal-card:hover { border-color: var(--primary); }
.deal-title { font-weight: 600; margin-bottom: 6px; font-size: 13px; }
.deal-meta { color: var(--text-dim); font-size: 12px; display: flex; justify-content: space-between; }

/* ==================== 模态框 ==================== */
.modal-mask {
  position: fixed; inset: 0; background: rgba(0,0,0,.6);
  display: flex; align-items: center; justify-content: center; z-index: 100;
  padding: 20px;
}
.modal {
  background: var(--bg-2); border: 1px solid var(--border);
  border-radius: 14px; width: 560px; max-width: 100%;
  max-height: 88vh; display: flex; flex-direction: column;
}
.modal-header {
  display: flex; justify-content: space-between; align-items: center;
  padding: 18px 22px; border-bottom: 1px solid var(--border);
}
.modal-header h3 { font-size: 16px; }
.modal-close {
  background: none; border: none; color: var(--text-dim);
  font-size: 22px; cursor: pointer; line-height: 1;
}
.modal-close:hover { color: var(--text); }
.modal-body { padding: 22px; overflow-y: auto; }
.modal-footer { display: flex; justify-content: flex-end; gap: 10px; margin-top: 20px; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }

/* ==================== 提醒列表 ==================== */
.followup-item {
  display: flex; gap: 14px; padding: 16px;
  background: var(--bg-2); border: 1px solid var(--border); border-radius: var(--radius);
  margin-bottom: 12px; align-items: flex-start;
}
.followup-item.overdue { border-left: 3px solid var(--danger); }
.followup-item.today { border-left: 3px solid var(--warning); }
.followup-item.future { border-left: 3px solid var(--primary); }
.followup-info { flex: 1; }
.followup-company { font-weight: 600; margin-bottom: 4px; }
.followup-note { color: var(--text-dim); font-size: 13px; margin-bottom: 6px; }
.followup-time { font-size: 12px; color: var(--text-dim); }
.empty-state { text-align: center; color: var(--text-dim); padding: 60px 20px; }
.empty-state .big { font-size: 40px; margin-bottom: 12px; }

/* ==================== 工具栏 ==================== */
.toolbar { display: flex; gap: 10px; margin-bottom: 16px; flex-wrap: wrap; align-items: center; }
.toolbar input, .toolbar select {
  background: var(--bg-2); border: 1px solid var(--border);
  border-radius: 8px; color: var(--text); padding: 9px 12px; font-size: 13px;
  outline: none; font-family: inherit;
}
.toolbar input:focus, .toolbar select:focus { border-color: var(--primary); }
.toolbar .search-input { flex: 1; min-width: 200px; }

/* ==================== Toast ==================== */
.toast {
  position: fixed; top: 20px; left: 50%; transform: translateX(-50%);
  background: var(--bg-3); color: var(--text); border: 1px solid var(--border);
  padding: 10px 22px; border-radius: 8px; z-index: 200; font-size: 14px;
  box-shadow: 0 8px 24px rgba(0,0,0,.4);
}
.toast.success { border-color: var(--success); }
.toast.error { border-color: var(--danger); }

/* ==================== 时间线（跟进记录） ==================== */
.timeline { position: relative; padding-left: 24px; }
.timeline::before {
  content: ""; position: absolute; left: 6px; top: 6px; bottom: 6px;
  width: 2px; background: var(--border);
}
.timeline-item { position: relative; padding-bottom: 20px; }
.timeline-item::before {
  content: ""; position: absolute; left: -24px; top: 4px;
  width: 10px; height: 10px; border-radius: 50%;
  background: var(--primary); border: 2px solid var(--bg-2);
}
.timeline-head { display: flex; gap: 10px; align-items: center; margin-bottom: 4px; font-size: 12px; color: var(--text-dim); }
.timeline-body { font-size: 13px; line-height: 1.6; }

/* ==================== 广告投放 ==================== */
.ad-card {
  background: var(--bg-2); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 20px;
}
.ad-card.paused { opacity: .65; }
.ad-head { display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: 14px; }
.ad-title { font-size: 15px; font-weight: 700; }
.ad-channel { color: var(--text-dim); font-size: 12px; margin-top: 3px; }
.progress-wrap { height: 10px; background: var(--bg-3); border-radius: 5px; overflow: hidden; margin: 8px 0; }
.progress-bar { height: 100%; border-radius: 5px; transition: width .3s; }
.progress-bar.ok { background: linear-gradient(90deg, var(--success), #4ad98c); }
.progress-bar.warn { background: linear-gradient(90deg, var(--warning), #f5c069); }
.progress-bar.over { background: linear-gradient(90deg, var(--danger), #ef8080); }
.ad-stats { display: flex; gap: 0; margin-top: 12px; }
.ad-stat { flex: 1; text-align: left; padding-right: 10px; }
.ad-stat-val { font-size: 15px; font-weight: 700; }
.ad-stat-label { font-size: 11px; color: var(--text-dim); margin-top: 2px; }
.ad-actions { display: flex; gap: 8px; margin-top: 14px; flex-wrap: wrap; }
.ad-period { font-size: 12px; color: var(--text-dim); }
.ad-log-item {
  display: flex; justify-content: space-between; align-items: center;
  padding: 10px 4px; border-bottom: 1px solid var(--border); font-size: 13px;
}
.ad-log-item:last-child { border-bottom: none; }
.ad-log-date { color: var(--text-dim); font-size: 12px; }

/* ==================== 用户权限 ==================== */
.perm-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-top: 8px; }
.perm-item {
  display: flex; align-items: center; gap: 8px;
  background: var(--bg-3); border: 1px solid var(--border);
  border-radius: 8px; padding: 10px 12px; cursor: pointer; font-size: 13px;
  transition: border .15s;
}
.perm-item:hover { border-color: var(--primary); }
.perm-item input { accent-color: var(--primary); }

/* ==================== 响应式 ==================== */
@media (max-width: 1024px) {
  .grid-4 { grid-template-columns: repeat(2, 1fr); }
  .form-row { grid-template-columns: 1fr; }
}
@media (max-width: 768px) {
  .sidebar { width: 64px; }
  .sidebar-brand { justify-content: center; padding: 16px 8px; }
  .sidebar-brand .brand-text { display: none; }
  .nav-item { justify-content: center; }
  .nav-item span:not(.nav-ico) { display: none; }
  .sidebar-footer { flex-direction: column; }
  .grid-4, .grid-2 { grid-template-columns: 1fr; }
}
