:root {
  --primary: #194189;
  --primary-light: #2a5bb8;
  --primary-bg: #eef2fb;
  --danger: #d9534f;
  --success: #28a745;
  --warning: #f0ad4e;
  --text: #2b2f36;
  --text-secondary: #6b7280;
  --border: #e5e7eb;
  --bg: #f3f4f6;
  --card: #ffffff;
  --shadow: 0 1px 3px rgba(0, 0, 0, 0.08), 0 1px 2px rgba(0, 0, 0, 0.04);
  --radius: 8px;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

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;
}

a { color: var(--primary); text-decoration: none; }

/* ---------- 登录页 ---------- */
.login-body {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #194189 0%, #2a5bb8 60%, #4a7bd0 100%);
}

.login-card {
  width: 380px;
  background: #fff;
  border-radius: 12px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.25);
  padding: 40px 36px 32px;
}

.login-logo {
  width: 64px;
  height: 64px;
  border-radius: 16px;
  background: var(--primary);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 28px;
  font-weight: 700;
  margin: 0 auto 16px;
}

.login-title {
  text-align: center;
  font-size: 20px;
  font-weight: 600;
  margin-bottom: 4px;
}

.login-sub {
  text-align: center;
  color: var(--text-secondary);
  font-size: 13px;
  margin-bottom: 28px;
}

.login-error {
  background: #fdecea;
  color: var(--danger);
  border-radius: 6px;
  padding: 8px 12px;
  font-size: 13px;
  margin-bottom: 16px;
  display: none;
}

.login-error.show { display: block; }

/* ---------- 表单 ---------- */
.form-group {
  margin-bottom: 16px;
}

.form-group label {
  display: block;
  font-size: 13px;
  color: var(--text-secondary);
  margin-bottom: 6px;
  font-weight: 500;
}

.form-group .hint {
  font-size: 12px;
  color: var(--text-secondary);
  margin-top: 4px;
}

.input {
  width: 100%;
  padding: 9px 12px;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 14px;
  outline: none;
  transition: border-color 0.15s;
  background: #fff;
  color: var(--text);
}

.input:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(25, 65, 137, 0.1); }

textarea.input { resize: vertical; min-height: 80px; }

/* ---------- 按钮 ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 9px 18px;
  border: 1px solid transparent;
  border-radius: 6px;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  background: var(--primary);
  color: #fff;
  transition: all 0.15s;
  line-height: 1.5;
}

.btn:hover { background: var(--primary-light); }
.btn:disabled { opacity: 0.6; cursor: not-allowed; }

.btn-block { width: 100%; }

.btn-secondary { background: #fff; color: var(--text); border-color: var(--border); }
.btn-secondary:hover { background: #f5f6f8; border-color: #d1d5db; }

.btn-danger { background: #fff; color: var(--danger); border-color: #f0c4c2; }
.btn-danger:hover { background: #fdecea; }

.btn-sm { padding: 5px 12px; font-size: 13px; }
.btn-xs { padding: 3px 10px; font-size: 12px; }

/* ---------- 后台布局 ---------- */
.layout {
  display: flex;
  min-height: 100vh;
}

.sidebar {
  width: 220px;
  background: #10263f;
  color: #cbd5e1;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
}

.sidebar-brand {
  padding: 20px 20px;
  font-size: 16px;
  font-weight: 600;
  color: #fff;
  display: flex;
  align-items: center;
  gap: 10px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.sidebar-brand .badge {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  background: #2a5bb8;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
}

.sidebar-nav { flex: 1; padding: 12px 0; }

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 11px 20px;
  cursor: pointer;
  color: #cbd5e1;
  font-size: 14px;
  transition: all 0.15s;
  border-left: 3px solid transparent;
}

.nav-item:hover { background: rgba(255, 255, 255, 0.06); color: #fff; }

.nav-item.active {
  background: rgba(42, 91, 184, 0.25);
  border-left-color: #4a7bd0;
  color: #fff;
}

.nav-item .icon { width: 18px; text-align: center; }

.sidebar-footer { padding: 16px 20px; border-top: 1px solid rgba(255, 255, 255, 0.08); font-size: 13px; }
.sidebar-footer .user { color: #fff; margin-bottom: 8px; display: flex; align-items: center; gap: 8px; }
.sidebar-footer .logout-btn {
  width: 100%;
  background: transparent;
  border: 1px solid rgba(255, 255, 255, 0.2);
  color: #cbd5e1;
  border-radius: 6px;
  padding: 7px;
  cursor: pointer;
  font-size: 13px;
}
.sidebar-footer .logout-btn:hover { background: rgba(255, 255, 255, 0.08); color: #fff; }

.main {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.topbar {
  background: var(--card);
  padding: 0 24px;
  height: 60px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--border);
  box-shadow: var(--shadow);
}

.topbar-title { font-size: 17px; font-weight: 600; }
.topbar-sub { font-size: 13px; color: var(--text-secondary); }

.content { padding: 24px; flex: 1; }

/* ---------- 卡片 ---------- */
.card {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  margin-bottom: 20px;
}

.card-header {
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 10px;
}

.card-header h3 { font-size: 15px; font-weight: 600; }
.card-body { padding: 20px; }

/* ---------- 表格 ---------- */
.table-wrap { overflow-x: auto; }

.table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}

.table th {
  text-align: left;
  padding: 10px 14px;
  background: #f9fafb;
  color: var(--text-secondary);
  font-weight: 500;
  font-size: 13px;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

.table td {
  padding: 10px 14px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}

.table tr:hover td { background: #fafbfc; }
.table tr:last-child td { border-bottom: none; }

/* ---------- 固定列：横向滚动时保持可见 ---------- */
/* 第一列（选择框）固定在最左侧 */
.table th:first-child,
.table td:first-child {
  position: sticky;
  left: 0;
  z-index: 4;
  background: #fff;
  box-shadow: 2px 0 4px rgba(0, 0, 0, 0.05);
  text-align: center;
}
.table thead th:first-child { background: #f9fafb; z-index: 6; }
.table tr:hover td:first-child { background: #fafbfc; }

/* 最后一列（操作按钮）固定在最右侧 */
.table th:last-child,
.table td:last-child {
  position: sticky;
  right: 0;
  z-index: 4;
  background: #fff;
  box-shadow: -2px 0 4px rgba(0, 0, 0, 0.05);
}
.table thead th:last-child { background: #f9fafb; z-index: 6; }
.table tr:hover td:last-child { background: #fafbfc; }

.table .actions {
  white-space: nowrap;
  text-align: right;
}
.table .actions .btn { margin-left: 6px; }
.table .actions .btn:first-child { margin-left: 0; }

.avatar-cell {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  object-fit: cover;
  background: #e5e7eb;
}

.thumb-cell {
  width: 64px;
  height: 36px;
  object-fit: cover;
  border-radius: 4px;
  background: #e5e7eb;
}

.ellipsis { max-width: 180px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* ---------- 徽章 ---------- */
.tag {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 12px;
  background: var(--primary-bg);
  color: var(--primary);
}

.tag-empty { background: #f1f2f4; color: var(--text-secondary); }

.tag-master { background: #fff3e0; color: #e65100; }
.tag-normal { background: #f1f2f4; color: var(--text-secondary); }

/* ---------- 弹窗 ---------- */
.modal-mask {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.45);
  z-index: 100;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 60px 16px 16px;
  overflow-y: auto;
  animation: fadeIn 0.15s;
}

.modal {
  background: #fff;
  border-radius: 10px;
  width: 100%;
  max-width: 560px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.2);
  animation: slideUp 0.2s;
  position: relative;
}

.modal-header {
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  cursor: move;
  user-select: none;
  -webkit-user-select: none;
}

.modal-header h4 { font-size: 16px; font-weight: 600; }
.modal-close { background: none; border: none; font-size: 20px; cursor: pointer; color: var(--text-secondary); }
.modal-close:hover { color: var(--text); }

.modal-body { padding: 20px; }

.modal-resizer {
  position: absolute;
  right: 0;
  bottom: 0;
  width: 18px;
  height: 18px;
  cursor: nwse-resize;
  z-index: 5;
  border-bottom-right-radius: 10px;
  background: linear-gradient(135deg, transparent 50%, rgba(0, 0, 0, 0.15) 50%);
  opacity: 0;
  transition: opacity 0.15s;
}
.modal:hover .modal-resizer { opacity: 1; }
.modal-resizer:hover,
.modal-resizer:active {
  opacity: 1;
  background: linear-gradient(135deg, transparent 50%, rgba(47, 107, 255, 0.5) 50%);
}
.modal-footer {
  padding: 14px 20px;
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: flex-end;
  gap: 10px;
}

@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes slideUp { from { transform: translateY(20px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }

/* ---------- 提示条 ---------- */
.toast-wrap {
  position: fixed;
  top: 20px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 200;
  display: flex;
  flex-direction: column;
  gap: 8px;
  align-items: center;
}

.toast {
  padding: 10px 20px;
  border-radius: 6px;
  color: #fff;
  font-size: 14px;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.15);
  animation: slideDown 0.2s;
  max-width: 80vw;
}

.toast-success { background: var(--success); }
.toast-error { background: var(--danger); }
.toast-info { background: var(--primary); }

@keyframes slideDown { from { transform: translateY(-20px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }

/* ---------- 工具 ---------- */
.row { display: flex; gap: 16px; flex-wrap: wrap; }
.row > * { flex: 1; min-width: 220px; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.text-secondary { color: var(--text-secondary); }
.mt-8 { margin-top: 8px; }
.mb-16 { margin-bottom: 16px; }
.empty-tip {
  text-align: center;
  color: var(--text-secondary);
  padding: 40px 0;
}

/* ---------- 图片上传 ---------- */
.upload-box {
  border: 2px dashed var(--border);
  border-radius: 8px;
  padding: 20px;
  text-align: center;
  cursor: pointer;
  transition: all 0.15s;
  background: #fafbfc;
}

.upload-box:hover { border-color: var(--primary); background: var(--primary-bg); }

.upload-box .upload-preview {
  max-width: 100%;
  max-height: 180px;
  border-radius: 6px;
  display: none;
  margin-bottom: 8px;
}

.upload-box .upload-tip { font-size: 13px; color: var(--text-secondary); }
.upload-box.has-image .upload-tip { display: none; }
.upload-box input[type="file"] { display: none; }

/* ---------- Banner 网格 ---------- */
.banner-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 16px;
}

.banner-item {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
}

.banner-item .banner-img {
  width: 100%;
  height: 130px;
  object-fit: cover;
  background: #f1f2f4;
  display: block;
}

.banner-item .banner-body { padding: 12px; }
.banner-item .banner-actions { display: flex; gap: 6px; margin-top: 8px; }
.banner-item .banner-actions .btn { flex: 1; }

/* ---------- 长图预览 ---------- */
.intro-preview {
  max-width: 100%;
  max-height: 400px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: #f1f2f4;
}

/* ---------- 筛选栏 ---------- */
.filter-bar {
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
  padding: 14px 20px;
  border-bottom: 1px solid var(--border);
  background: #fafbfc;
}

.filter-bar .search-input { flex: 1; min-width: 220px; }
.filter-bar select.input { width: auto; min-width: 140px; }
.filter-bar .filter-count {
  font-size: 12px;
  color: var(--text-secondary);
  white-space: nowrap;
}

/* ---------- 头像批量导入 ---------- */
.avatar-thumbs {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 10px;
}

.avatar-thumbs .thumb-item {
  width: 52px;
  height: 52px;
  border-radius: 8px;
  border: 1px solid var(--border);
  object-fit: cover;
  background: #f1f2f4;
}

/* ---------- 排序按钮 ---------- */
.sort-btns { display: flex; gap: 3px; flex-wrap: wrap; min-width: 92px; }
.sort-btns .btn-xs { padding: 2px 6px; font-size: 12px; }
.sort-btns .btn-xs[data-sort-top],
.sort-btns .btn-xs[data-sort-bottom] { font-weight: 600; }

/* ---------- 信息缺失 / 异常标记 ---------- */
.issue-badges { display: flex; gap: 4px; margin-top: 4px; flex-wrap: wrap; }
.issue-badge {
  display: inline-block;
  font-size: 11px;
  line-height: 1;
  padding: 2px 6px;
  border-radius: 4px;
  cursor: help;
}
.issue-badge.issue-missing { color: #b45309; background: #fef3c7; border: 1px solid #fde68a; }
.issue-badge.issue-error { color: #b91c1c; background: #fee2e2; border: 1px solid #fecaca; }

/* ---------- 分享弹窗 ---------- */
.share-emp-info { display: flex; align-items: center; gap: 12px; }
.share-emp-info .avatar-cell { width: 44px; height: 44px; border-radius: 8px; object-fit: cover; }
.share-qr {
  display: block;
  width: 140px;
  height: 140px;
  object-fit: contain;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #fff;
  padding: 4px;
}

/* ---------- 批量选择（多选） ---------- */
.batch-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 16px;
  background: var(--primary-bg, #eef4ff);
  border-bottom: 1px solid var(--border);
  flex-wrap: wrap;
}
.batch-bar .batch-count {
  font-size: 13px;
  font-weight: 600;
  color: var(--primary, #2f6bff);
}
.table th input[type="checkbox"],
.table td input[type="checkbox"] {
  width: 15px;
  height: 15px;
  cursor: pointer;
  accent-color: var(--primary, #2f6bff);
  vertical-align: middle;
}

/* ---------- 批量分享弹窗 ---------- */
.share-tip {
  font-size: 13px;
  color: #6b7280;
  margin-bottom: 12px;
  background: #f8fafc;
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 10px 12px;
  line-height: 1.6;
}
.modal-body.share-body {
  max-height: 62vh;
  overflow-y: auto;
}
.share-list {
  max-height: 380px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: 12px;
}
.share-card {
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 12px;
  background: #fafbfc;
}
.share-card-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
  font-size: 13px;
  flex-wrap: wrap;
}
.share-card-actions { display: flex; gap: 6px; }
.share-card-text {
  white-space: pre-wrap;
  word-break: break-all;
  font-size: 13px;
  line-height: 1.6;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 8px 10px;
  margin: 0 0 8px;
  font-family: inherit;
}
.share-card-qr-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
  font-size: 12px;
}
.share-qr-mini {
  width: 56px;
  height: 56px;
  object-fit: contain;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: #fff;
}
.share-qr-result { margin-top: 8px; }

/* 批量生成小程序码结果 */
.batch-qr-result { margin-top: 12px; }
.qr-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 12px;
  margin-top: 10px;
}
.qr-grid-item {
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px;
  text-align: center;
  background: #fff;
}
.qr-grid-item img.share-qr { width: 100%; height: auto; }
.qr-grid-name { font-weight: 600; margin-top: 6px; font-size: 14px; }
.qr-grid-file { font-size: 12px; color: var(--text-secondary); word-break: break-all; margin-top: 2px; }
.qr-grid-item .btn { margin-top: 8px; }

/* 分享方式选项卡（小程序码 / 文字链接） */
.share-tabs {
  display: flex;
  gap: 8px;
  border-bottom: 1px solid var(--border);
  padding-bottom: 12px;
  margin-bottom: 16px;
}
.share-tab {
  padding: 8px 22px;
  border: 1px solid #d1d5db;
  background: #fff;
  border-radius: 8px;
  cursor: pointer;
  font-size: 14px;
  color: #374151;
  font-weight: 500;
  transition: all 0.15s;
}
.share-tab:hover { border-color: var(--primary, #2f6bff); color: var(--primary, #2f6bff); }
.share-tab.active {
  background: var(--primary, #2f6bff);
  border-color: var(--primary, #2f6bff);
  color: #fff;
}
.share-tab-panel { display: none; }
.share-tab-panel.active { display: block; }
.share-qr-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 10px;
}

/* 邮箱发送结果 */
.email-send-result { margin-top: 12px; }
.email-result-list { margin: 8px 0 0; padding-left: 20px; font-size: 13px; line-height: 1.8; max-height: 200px; overflow-y: auto; }
.email-result-ok { color: #16a34a; }
.email-result-fail { color: #b91c1c; }

/* 设置页分隔线 */
.setting-divider { border: none; border-top: 1px solid var(--border); margin: 16px 0; }

/* ---------- 表格列宽拖动 ---------- */
.table th { position: relative; }
.col-resizer {
  position: absolute;
  top: 0;
  right: 0;
  width: 8px;
  height: 100%;
  cursor: col-resize;
  z-index: 10;
  background: transparent;
  transition: background 0.15s;
}
.col-resizer::after {
  content: '';
  position: absolute;
  top: 25%;
  right: 1px;
  width: 2px;
  height: 50%;
  background: rgba(0,0,0,0.08);
  border-radius: 1px;
}
.col-resizer:hover,
.col-resizer:active {
  background: rgba(47, 107, 255, 0.15);
}
.col-resizer:hover::after,
.col-resizer:active::after {
  background: rgba(47, 107, 255, 0.5);
}

/* ---------- 头像裁剪器 ---------- */
.crop-wrap canvas { display: block; width: 100%; height: 100%; }

@media (max-width: 768px) {
  .sidebar { width: 64px; }
  .sidebar-brand span, .sidebar-footer { display: none; }
  .nav-item { justify-content: center; padding: 12px 0; }
  .grid-2 { grid-template-columns: 1fr; }
}
