/* ==========================================================
   CRM 系统样式 - 深色侧边栏 + Element风格 + 移动端适配
   ========================================================== */
* { box-sizing: border-box; margin: 0; padding: 0; }
body {
  font-family: -apple-system, "PingFang SC", "Microsoft YaHei", "Helvetica Neue", sans-serif;
  background: #f0f2f5;
  color: #303133;
  font-size: 14px;
}
a { color: #409eff; text-decoration: none; }
a:hover { color: #66b1ff; }

/* ---------- 布局 ---------- */
.layout { display: flex; min-height: 100vh; }
.sidebar {
  width: 200px; background: #001529; color: rgba(255,255,255,.65);
  flex-shrink: 0; display: flex; flex-direction: column;
  position: sticky; top: 0; height: 100vh;
}
.sidebar .brand {
  height: 56px; display: flex; align-items: center; padding: 0 20px;
  color: #fff; font-size: 15px; font-weight: 600;
  border-bottom: 1px solid rgba(255,255,255,.08);
}
.sidebar .group-title {
  padding: 16px 20px 6px; font-size: 12px; color: rgba(255,255,255,.35);
}
.sidebar a {
  display: flex; align-items: center; gap: 8px;
  padding: 12px 20px; color: rgba(255,255,255,.75);
  border-left: 3px solid transparent;
}
.sidebar a:hover { color: #fff; background: rgba(255,255,255,.05); }
.sidebar a.active {
  color: #fff; background: #1890ff; border-left-color: #fff;
}
.sidebar-footer { margin-top: auto; padding: 12px 20px; border-top: 1px solid rgba(255,255,255,.08); }
.sidebar-footer .logout-link { color: rgba(255,255,255,.5); font-size: 13px; }

.main { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.topbar {
  height: 56px; background: #fff; display: flex; align-items: center;
  justify-content: space-between; padding: 0 24px;
  box-shadow: 0 1px 4px rgba(0,21,41,.08);
  position: sticky; top: 0; z-index: 50;
}
.topbar .left { display: flex; align-items: center; gap: 10px; }
.topbar .crumb { color: #606266; font-size: 14px; }
.topbar .right { display: flex; align-items: center; gap: 8px; }
.topbar .avatar {
  width: 32px; height: 32px; border-radius: 50%; background: #1890ff;
  color: #fff; display: inline-flex; align-items: center; justify-content: center;
  font-size: 13px;
}
.menu-btn {
  display: none; background: none; border: none; font-size: 22px;
  cursor: pointer; color: #303133; padding: 4px 8px; line-height: 1;
}
.mask { display: none; }

.content { padding: 16px 24px; flex: 1; }

/* ---------- 卡片 ---------- */
.card {
  background: #fff; border-radius: 4px; padding: 20px;
  box-shadow: 0 1px 2px rgba(0,0,0,.03);
}
.card + .card { margin-top: 16px; }

/* ---------- 页面头 ---------- */
.page-head {
  display: flex; justify-content: space-between; align-items: center;
  margin-bottom: 16px; flex-wrap: wrap; gap: 8px;
}
.page-head h2 { font-size: 16px; font-weight: 500; }
.page-head .actions { display: flex; gap: 8px; flex-wrap: wrap; }

/* ---------- 表格 ---------- */
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
table.grid { width: 100%; border-collapse: collapse; background: #fff; min-width: 760px; }
table.grid th, table.grid td {
  padding: 12px; text-align: left; border-bottom: 1px solid #ebeef5;
  font-size: 13px; white-space: nowrap;
}
table.grid th {
  background: #fafafa; color: #909399; font-weight: 500;
}
table.grid tr:hover td { background: #f5f7fa; }
td .btn + .btn { margin-left: 6px; }

/* ---------- 按钮 ---------- */
.btn {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 8px 16px; border-radius: 4px; border: 1px solid transparent;
  cursor: pointer; font-size: 13px; background: #fff;
}
.btn-primary { background: #1890ff; color: #fff; border-color: #1890ff; }
.btn-primary:hover { background: #40a9ff; border-color: #40a9ff; }
.btn-success { background: #52c41a; color: #fff; border-color: #52c41a; }
.btn-danger  { background: #fff; color: #ff4d4f; border-color: #ff4d4f; }
.btn-default { background: #fff; color: #606266; border-color: #dcdfe6; }
.btn-default:hover { color: #409eff; border-color: #c6e2ff; background: #ecf5ff; }
.btn-sm { padding: 4px 10px; font-size: 12px; }
.btn-block { width: 100%; }

/* ---------- 标签 ---------- */
.tag {
  display: inline-block; padding: 2px 8px; border-radius: 4px; font-size: 12px;
}
.tag-blue   { background: #ecf5ff; color: #409eff; border: 1px solid #d9ecff; }
.tag-green  { background: #f0f9eb; color: #67c23a; border: 1px solid #e1f3d8; }
.tag-orange { background: #fdf6ec; color: #e6a23c; border: 1px solid #faecd8; }
.tag-red    { background: #fef0f0; color: #f56c6c; border: 1px solid #fde2e2; }
.tag-gray   { background: #f4f4f5; color: #909399; border: 1px solid #e9e9eb; }

/* ---------- 表单 ---------- */
.form-row { margin-bottom: 16px; }
.form-row label { display: block; margin-bottom: 6px; color: #606266; font-size: 13px; }
.form-row input, .form-row select, .form-row textarea {
  width: 100%; padding: 8px 12px; border: 1px solid #dcdfe6; border-radius: 4px;
  font-size: 14px; font-family: inherit; outline: none; background: #fff;
}
.form-row input:focus, .form-row select:focus, .form-row textarea:focus {
  border-color: #409eff;
}
.form-row textarea { min-height: 80px; resize: vertical; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0 24px; }

/* ---------- 提示 ---------- */
.alert { padding: 10px 14px; border-radius: 4px; margin-bottom: 14px; font-size: 13px; }
.alert-success { background: #f0f9eb; color: #67c23a; border: 1px solid #e1f3d8; }
.alert-error   { background: #fef0f0; color: #f56c6c; border: 1px solid #fde2e2; }
.muted { color: #909399; font-size: 13px; }
.empty {
  text-align: center; padding: 60px 0; color: #c0c4cc;
}

/* ---------- 登录 ---------- */
.login-body {
  background: linear-gradient(135deg, #1890ff, #001529);
  display: flex; align-items: center; justify-content: center; min-height: 100vh;
  padding: 16px;
}
.login-box {
  background: #fff; padding: 36px; border-radius: 8px;
  width: 360px; max-width: 100%; box-shadow: 0 10px 40px rgba(0,0,0,.2);
}
.login-box h1 { font-size: 20px; margin-bottom: 6px; text-align: center; }
.login-box .muted { text-align: center; margin-bottom: 20px; }

/* ---------- 工作台统计 ---------- */
.stat-row { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; margin-bottom: 16px; }
.stat {
  background: #fff; border-radius: 4px; padding: 20px;
  border-top: 3px solid #1890ff;
}
.stat .label { color: #909399; font-size: 13px; margin-bottom: 8px; }
.stat .num { font-size: 28px; font-weight: 600; color: #303133; }
.stat.warn { border-top-color: #f56c6c; }
.stat.ok   { border-top-color: #52c41a; }

/* ---------- 时间线 ---------- */
.timeline { border-left: 2px solid #e8e8e8; padding-left: 20px; margin-left: 8px; }
.timeline-item { margin-bottom: 20px; position: relative; }
.timeline-item::before {
  content: ''; position: absolute; left: -26px; top: 4px;
  width: 10px; height: 10px; border-radius: 50%; background: #1890ff;
}
.timeline-item .meta { color: #909399; font-size: 12px; margin-bottom: 6px; }
.timeline-item .meta .who { color: #303133; font-weight: 500; margin-right: 8px; }

/* ---------- 详情页 ---------- */
.detail-head {
  display: flex; justify-content: space-between; align-items: center;
  margin-bottom: 16px; flex-wrap: wrap; gap: 8px;
}
.detail-head h2 { font-size: 18px; }
.detail-grid {
  display: grid; grid-template-columns: 1fr 1fr; gap: 16px 40px;
}
.detail-grid .item { display: flex; font-size: 13px; }
.detail-grid .item .k { color: #909399; width: 100px; flex-shrink: 0; }
.detail-grid .item .v { color: #303133; }

.tabs { border-bottom: 1px solid #e8e8e8; margin-bottom: 16px; display: flex; gap: 24px; }
.tabs a {
  padding: 10px 4px; color: #606266; border-bottom: 2px solid transparent;
}
.tabs a.active { color: #1890ff; border-bottom-color: #1890ff; }

.tag-overdue { color: #f56c6c; font-weight: 500; }
.tag-today { color: #e6a23c; font-weight: 500; }

/* ==========================================================
   移动端适配（<=768px）
   ========================================================== */
@media (max-width: 768px) {
  body { font-size: 15px; }

  /* 侧边栏抽屉 */
  .sidebar {
    position: fixed; left: 0; top: 0; z-index: 100;
    width: 240px; height: 100%;
    transform: translateX(-100%);
    transition: transform .25s ease;
    overflow-y: auto;
  }
  .sidebar.open { transform: translateX(0); }
  .sidebar .brand { height: 52px; }
  .sidebar a { padding: 14px 20px; font-size: 15px; }
  .sidebar .group-title { padding-top: 14px; }

  /* 遮罩 */
  .mask {
    display: block; position: fixed; inset: 0; z-index: 90;
    background: rgba(0,0,0,.45); opacity: 0; pointer-events: none;
    transition: opacity .25s ease;
  }
  .mask.show { opacity: 1; pointer-events: auto; }

  /* 顶栏 */
  .menu-btn { display: inline-block; }
  .topbar { padding: 0 12px; height: 52px; }
  .topbar .uname { display: none; }
  .topbar .crumb { font-size: 13px; }

  /* 内容区 */
  .content { padding: 12px 12px 20px; }

  /* 卡片 */
  .card { padding: 14px; border-radius: 8px; }
  .card + .card { margin-top: 12px; }

  /* 统计块 2x2 */
  .stat-row { grid-template-columns: 1fr 1fr; gap: 10px; }
  .stat { padding: 14px; }
  .stat .num { font-size: 24px; }

  /* 表格横向滚动 */
  .table-wrap { margin: 0 -14px; padding: 0 14px; }
  table.grid { min-width: 700px; }
  table.grid th, table.grid td { padding: 10px 8px; font-size: 13px; }

  /* 表单单列 */
  .form-grid { grid-template-columns: 1fr; }

  /* 详情网格单列 */
  .detail-grid { grid-template-columns: 1fr; gap: 12px; }

  /* 按钮触屏友好 */
  .btn { padding: 10px 16px; }
  .btn-sm { padding: 6px 12px; }

  /* 跟进输入区 */
  .timeline { padding-left: 16px; }

  /* 页面头 */
  .page-head { flex-direction: column; align-items: flex-start; }
  .page-head .actions { width: 100%; }
  .page-head .actions form, .page-head .actions input, .page-head .actions select { width: 100%; }
}
