/* ============================================================
   客户管理系统 - 灰色简约风格
   设计原则：灰阶为主，白底内容，浅灰边框，特殊状态用红色
   ============================================================ */

/* ---------- 基础重置 ---------- */
* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
body {
  font-family: -apple-system, "PingFang SC", "Microsoft YaHei", "Segoe UI", Roboto, sans-serif;
  background: #f5f5f5;
  color: #333;
  font-size: 14px;
  line-height: 1.6;
}
a { color: #555; text-decoration: none; }
a:hover { color: #222; }

/* ---------- 布局：侧边栏 + 主区 ---------- */
.app-layout { display: flex; min-height: 100vh; }

/* 侧边栏 */
.sidebar {
  width: 210px;
  background: #ececec;
  border-right: 1px solid #dcdcdc;
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
}
.sidebar .logo {
  padding: 18px 20px;
  font-size: 16px;
  font-weight: 700;
  color: #444;
  border-bottom: 1px solid #dcdcdc;
  letter-spacing: 0.5px;
}
.sidebar .nav-section {
  padding: 10px 0;
  border-bottom: 1px solid #e0e0e0;
}
.sidebar .nav-section:last-child { border-bottom: none; }
.sidebar .nav-title {
  padding: 6px 20px;
  font-size: 11px;
  color: #999;
  text-transform: uppercase;
  letter-spacing: 1px;
}
.sidebar .nav-link {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 20px;
  color: #555;
  font-size: 14px;
  border-left: 3px solid transparent;
  transition: background 0.15s, color 0.15s;
}
.sidebar .nav-link:hover {
  background: #e0e0e0;
  color: #222;
  text-decoration: none;
}
.sidebar .nav-link.active {
  background: #ddd;
  color: #222;
  font-weight: 600;
  border-left-color: #666;
}
.sidebar .nav-link .nav-icon {
  width: 18px;
  text-align: center;
  font-size: 15px;
  opacity: 0.8;
}
.sidebar .sidebar-footer {
  margin-top: auto;
  padding: 12px 20px;
  border-top: 1px solid #dcdcdc;
  font-size: 12px;
  color: #999;
}

/* 主内容区 */
.main-wrap { flex: 1; display: flex; flex-direction: column; min-width: 0; }

/* 顶部栏 */
.topbar {
  height: 50px;
  background: #fff;
  border-bottom: 1px solid #e0e0e0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  flex-shrink: 0;
}
.topbar .page-title {
  font-size: 15px;
  font-weight: 600;
  color: #333;
}
.topbar .topbar-right {
  display: flex;
  align-items: center;
  gap: 16px;
}
.topbar .user-info {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: #666;
  position: relative;
  cursor: pointer;
}
.topbar .user-menu {
  display: none;
  position: absolute;
  top: 34px;
  right: 0;
  background: #fff;
  border: 1px solid #e0e0e0;
  border-radius: 6px;
  box-shadow: 0 6px 20px rgba(0,0,0,.12);
  min-width: 140px;
  z-index: 1000;
  padding: 6px 0;
}
.topbar .user-menu.open { display: block; }
.topbar .user-menu a {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 9px 16px;
  font-size: 13px;
  color: #444;
  text-decoration: none;
  white-space: nowrap;
}
.topbar .user-menu a:hover { background: #f5f5f5; }
.topbar .user-avatar {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: #bbb;
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 600;
}
.topbar .logout-btn {
  font-size: 13px;
  color: #888;
  padding: 4px 10px;
  border: 1px solid #ddd;
  border-radius: 4px;
  background: #fafafa;
}
.topbar .logout-btn:hover { background: #f0f0f0; color: #555; }

/* 内容容器 */
.container {
  flex: 1;
  padding: 20px 24px;
  overflow-y: auto;
}

/* ---------- 通用组件 ---------- */

/* 卡片/面板 */
.panel {
  background: #fff;
  border: 1px solid #e3e3e3;
  border-radius: 4px;
  padding: 18px;
  margin-bottom: 16px;
}
.panel-title {
  font-size: 14px;
  font-weight: 600;
  color: #333;
  margin-bottom: 14px;
  padding-bottom: 10px;
  border-bottom: 1px solid #eee;
}

/* 统计卡片 */
.cards { display: flex; gap: 14px; flex-wrap: wrap; margin-bottom: 16px; }
.card {
  background: #fff;
  border: 1px solid #e3e3e3;
  border-radius: 4px;
  padding: 16px 20px;
  min-width: 140px;
  flex: 1;
}
.card .card-label { font-size: 12px; color: #999; margin-bottom: 6px; }
.card .num { font-size: 26px; font-weight: 700; color: #333; }
.card .num.text-danger { color: #c0392b; }
.card .num.text-muted { color: #999; }
.card .card-sub { font-size: 12px; color: #aaa; margin-top: 4px; }

/* 表格 */
.table-wrap {
  background: #fff;
  border: 1px solid #e3e3e3;
  border-radius: 4px;
  overflow: hidden;
  margin-bottom: 16px;
}
table { width: 100%; border-collapse: collapse; }
th, td {
  padding: 10px 14px;
  text-align: left;
  border-bottom: 1px solid #eee;
  font-size: 13px;
}
th {
  background: #f7f7f7;
  color: #666;
  font-weight: 600;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.3px;
  border-bottom: 1px solid #e0e0e0;
}
tr:last-child td { border-bottom: none; }
tr:hover td { background: #fafafa; }
td .muted { color: #aaa; font-size: 12px; }

/* 表单 */
.form-group { margin-bottom: 14px; }
label {
  display: block;
  font-size: 12px;
  color: #666;
  margin-bottom: 5px;
  font-weight: 500;
}
input[type="text"], input[type="password"], input[type="email"],
input[type="number"], input[type="datetime-local"], input[type="date"],
select, textarea {
  width: 100%;
  padding: 7px 10px;
  border: 1px solid #d0d0d0;
  border-radius: 3px;
  font-size: 13px;
  font-family: inherit;
  background: #fff;
  color: #333;
  transition: border-color 0.15s;
}
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: #888;
  box-shadow: 0 0 0 2px rgba(0,0,0,0.05);
}
textarea { min-height: 80px; resize: vertical; }
input[type="color"] { height: 32px; padding: 2px; cursor: pointer; }
input[type="file"] { font-size: 13px; }

/* 按钮 */
.btn, button {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  background: #e8e8e8;
  color: #444;
  border: 1px solid #d0d0d0;
  padding: 7px 16px;
  border-radius: 3px;
  font-size: 13px;
  cursor: pointer;
  font-family: inherit;
  transition: background 0.15s, border-color 0.15s;
  text-decoration: none;
}
.btn:hover, button:hover {
  background: #ddd;
  border-color: #c0c0c0;
  color: #222;
  text-decoration: none;
}
.btn-primary {
  background: #555;
  color: #fff;
  border-color: #555;
}
.btn-primary:hover { background: #444; border-color: #444; color: #fff; }
.btn-danger {
  background: #fff;
  color: #c0392b;
  border-color: #e0b0b0;
}
.btn-danger:hover { background: #fdf0f0; border-color: #c0392b; }
.btn-sm { padding: 4px 10px; font-size: 12px; }
.btn-block { width: 100%; justify-content: center; }

/* 工具栏 */
.toolbar {
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
  margin-bottom: 14px;
}
.toolbar input, .toolbar select { width: auto; }
.toolbar .spacer { flex: 1; }

/* 提示框 */
.alert {
  padding: 10px 14px;
  border-radius: 3px;
  margin-bottom: 14px;
  font-size: 13px;
  border: 1px solid transparent;
}
.alert-success { background: #f0f7f0; color: #2d6a2d; border-color: #c8e0c8; }
.alert-danger { background: #fdf0f0; color: #c0392b; border-color: #f0c0c0; }
.alert-info { background: #f0f4f8; color: #446; border-color: #d0d8e0; }
.alert-warning { background: #fdf8f0; color: #8a6d00; border-color: #f0e0b0; }

/* 徽章 */
.badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 2px;
  font-size: 11px;
  font-weight: 500;
  background: #e8e8e8;
  color: #666;
}
.badge-success { background: #e8f0e8; color: #2d6a2d; }
.badge-warning { background: #f5f0e0; color: #8a6d00; }
.badge-danger { background: #f8e8e8; color: #c0392b; }
.badge-muted { background: #f0f0f0; color: #999; }
.badge-info { background: #e8eef5; color: #556; }

/* 文字颜色 */
.text-danger { color: #c0392b; }
.text-success { color: #2d6a2d; }
.text-muted { color: #999; }
.text-warning { color: #8a6d00; }
.text-small { font-size: 12px; }

/* 网格布局 */
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.grid3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 16px; }
.grid-form { display: grid; grid-template-columns: 1fr 1fr; gap: 0 20px; align-items: start; }
.grid-form select[multiple] { min-height: 120px; }

/* 分页 */
.pagination {
  display: flex;
  gap: 4px;
  align-items: center;
  margin: 14px 0;
  font-size: 13px;
}
.pagination a, .pagination span {
  padding: 5px 10px;
  border: 1px solid #ddd;
  border-radius: 3px;
  background: #fff;
  color: #555;
}
.pagination a:hover { background: #f0f0f0; border-color: #ccc; }
.pagination .cur { background: #666; color: #fff; border-color: #666; }
.pagination .disabled { color: #ccc; cursor: not-allowed; }

/* Tab */
.tabs {
  display: flex;
  border-bottom: 1px solid #e0e0e0;
  margin-bottom: 16px;
}
.tab {
  padding: 9px 18px;
  font-size: 13px;
  color: #777;
  cursor: pointer;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  transition: color 0.15s;
}
.tab:hover { color: #333; }
.tab.active { color: #333; font-weight: 600; border-bottom-color: #666; }
.tab-content { display: none; }
.tab-content.active { display: block; }

/* 进度条 */
.progress {
  height: 6px;
  background: #eee;
  border-radius: 3px;
  overflow: hidden;
}
.progress-bar {
  height: 100%;
  background: #888;
  border-radius: 3px;
  transition: width 0.3s;
}
.progress-bar.danger { background: #c0392b; }

/* 时间线 */
.timeline { border-left: 2px solid #e0e0e0; margin-left: 6px; padding-left: 16px; }
.tl-item { position: relative; padding: 8px 0; }
.tl-item::before {
  content: '';
  position: absolute;
  left: -21px;
  top: 14px;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #aaa;
  border: 2px solid #fff;
}
.tl-item .tl-time { font-size: 11px; color: #aaa; }
.tl-item .tl-type { font-weight: 600; color: #555; font-size: 13px; }

/* 复选框网格 */
.check-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 6px;
}
.check-item {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 10px;
  background: #f7f7f7;
  border: 1px solid #e8e8e8;
  border-radius: 3px;
  font-size: 13px;
  cursor: pointer;
}
.check-item:hover { background: #f0f0f0; }
.check-item input[type="checkbox"] { cursor: pointer; }

/* 变量标签 */
.var-chip {
  display: inline-block;
  padding: 3px 8px;
  background: #f0f0f0;
  color: #555;
  border-radius: 3px;
  font-size: 12px;
  margin: 2px;
  cursor: pointer;
  border: 1px solid #e0e0e0;
}
.var-chip:hover { background: #e8e8e8; }

/* 模态框 */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.4);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 100;
}
.modal-backdrop.open { display: flex; }
.modal {
  background: #fff;
  border-radius: 4px;
  padding: 22px;
  max-width: 560px;
  width: 92%;
  max-height: 85vh;
  overflow-y: auto;
  border: 1px solid #ddd;
}
.modal h3 { margin-bottom: 14px; font-size: 15px; }

/* Toast */
.toast-container {
  position: fixed;
  top: 20px;
  right: 20px;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.toast {
  background: #fff;
  border: 1px solid #ddd;
  border-left: 3px solid #888;
  border-radius: 3px;
  padding: 10px 16px;
  font-size: 13px;
  color: #333;
  box-shadow: 0 2px 8px rgba(0,0,0,0.1);
  min-width: 240px;
  animation: slideIn 0.2s ease;
}
.toast.success { border-left-color: #2d6a2d; }
.toast.error { border-left-color: #c0392b; }
.toast.warning { border-left-color: #8a6d00; }
@keyframes slideIn {
  from { transform: translateX(100%); opacity: 0; }
  to { transform: translateX(0); opacity: 1; }
}

/* 登录页 */
.login-page {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  background: #f0f0f0;
}
.login-box {
  width: 360px;
  background: #fff;
  border: 1px solid #ddd;
  border-radius: 4px;
  padding: 30px;
}
.login-box h2 {
  text-align: center;
  font-size: 18px;
  margin-bottom: 20px;
  color: #444;
}

/* 富文本编辑器（Quill 覆盖） */
.ql-container { font-size: 14px; }
.ql-toolbar { border-radius: 3px 3px 0 0; }
.ql-container { border-radius: 0 0 3px 3px; min-height: 280px; }
.ql-editor { min-height: 280px; }

/* 筛选 Tab */
.filter-tabs {
  display: flex;
  gap: 0;
  margin-bottom: 14px;
  border-bottom: 1px solid #e0e0e0;
}
.filter-tab {
  padding: 8px 16px;
  font-size: 13px;
  color: #777;
  cursor: pointer;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
}
.filter-tab:hover { color: #333; }
.filter-tab.active { color: #333; font-weight: 600; border-bottom-color: #666; }
.filter-tab .count {
  display: inline-block;
  background: #eee;
  color: #888;
  padding: 0 6px;
  border-radius: 8px;
  font-size: 11px;
  margin-left: 4px;
}

/* 行内操作 */
.row-actions { display: flex; gap: 8px; align-items: center; flex-wrap: nowrap; white-space: nowrap; }
.row-actions a, .row-actions button { font-size: 12px; padding: 3px 8px; }

/* 空状态 */
.empty-state {
  text-align: center;
  padding: 40px 20px;
  color: #aaa;
}
.empty-state .empty-icon { font-size: 36px; margin-bottom: 10px; opacity: 0.4; }

/* 发送进度固定条 */
.send-progress-bar {
  position: sticky;
  top: 0;
  background: #fff;
  border-bottom: 1px solid #e0e0e0;
  padding: 10px 24px;
  z-index: 10;
  display: none;
  align-items: center;
  gap: 14px;
}
.send-progress-bar.show { display: flex; }
.send-progress-bar .progress { flex: 1; max-width: 400px; }

/* 响应式 */
@media (max-width: 900px) {
  .sidebar { width: 60px; }
  .sidebar .logo span, .sidebar .nav-link span:not(.nav-icon), .sidebar .nav-title, .sidebar .sidebar-footer { display: none; }
  .sidebar .nav-link { justify-content: center; padding: 12px; }
  .grid2, .grid3, .grid-form { grid-template-columns: 1fr; }
}
@media (max-width: 600px) {
  .container { padding: 12px; }
  .cards .card { min-width: 100%; }
  .topbar { padding: 0 12px; }
}
