/**
 * ================================================
 * 伴伴Nami · Web客服后台 - 样式表
 * ================================================
 * 主题色：#FF8C42（与小程序一致）
 * 风格：现代化管理后台 · 浅色 · 卡片式
 * ================================================
 */

/* ===== CSS 变量 ===== */
:root {
  --primary: #FF8C42;
  --primary-dark: #F2731A;
  --primary-light: #FFB78A;
  --primary-bg: #FFF4EC;
  --primary-bg-hover: #FFE6D5;

  --success: #34C759;
  --success-bg: #E8F9EE;
  --warning: #FF9F0A;
  --warning-bg: #FFF4E0;
  --danger: #FF3B30;
  --danger-bg: #FFEBE9;
  --info: #007AFF;
  --info-bg: #E6F2FF;
  --purple: #AF52DE;
  --purple-bg: #F4E8FB;

  --text-1: #1A1A1A;
  --text-2: #4A4A4A;
  --text-3: #8A8A8A;
  --text-4: #B0B0B0;

  --bg-page: #F5F6F8;
  --bg-card: #FFFFFF;
  --bg-hover: #F8F9FB;

  --border: #ECEEF1;
  --border-light: #F2F3F5;

  --shadow-sm: 0 1px 2px rgba(20, 26, 38, 0.04);
  --shadow-md: 0 4px 12px rgba(20, 26, 38, 0.06);
  --shadow-lg: 0 8px 24px rgba(20, 26, 38, 0.1);

  --radius-sm: 6px;
  --radius-md: 8px;
  --radius-lg: 12px;

  --sidebar-width: 220px;
  --sidebar-collapsed: 64px;
  --topbar-height: 60px;

  --font: -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei",
          "Helvetica Neue", Helvetica, Arial, sans-serif;
}

/* ===== 重置 ===== */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html, body {
  height: 100%;
  font-family: var(--font);
  font-size: 14px;
  color: var(--text-1);
  background: var(--bg-page);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

button, input, select, textarea {
  font-family: inherit;
  font-size: inherit;
  color: inherit;
  outline: none;
}

a {
  color: var(--primary);
  text-decoration: none;
  cursor: pointer;
}

.hidden {
  display: none !important;
}

/* ============ 登录页面 ============ */
.login-screen {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #FF8C42 0%, #FF6B2B 50%, #F2731A 100%);
  position: relative;
  overflow: hidden;
  padding: 20px;
}

.login-screen::before,
.login-screen::after {
  content: '';
  position: absolute;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.08);
}

.login-screen::before {
  width: 480px;
  height: 480px;
  top: -160px;
  right: -120px;
}

.login-screen::after {
  width: 320px;
  height: 320px;
  bottom: -100px;
  left: -80px;
}

.login-card {
  position: relative;
  z-index: 1;
  width: 100%;
  max-width: 380px;
  background: #fff;
  border-radius: 16px;
  padding: 40px 36px 32px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.2);
  text-align: center;
}

.login-logo {
  display: flex;
  justify-content: center;
  margin-bottom: 18px;
}

.logo-icon {
  width: 80px;
  height: 80px;
  object-fit: contain;
  display: block;
}

.logo-icon.small {
  width: 32px;
  height: 32px;
}

.login-title {
  font-size: 22px;
  font-weight: 600;
  color: var(--text-1);
  margin-bottom: 6px;
}

.login-subtitle {
  color: var(--text-3);
  font-size: 13px;
  margin-bottom: 28px;
}

.login-form {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.login-input {
  width: 100%;
  height: 44px;
  padding: 0 16px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-md);
  background: #FAFBFC;
  transition: all 0.2s;
  text-align: center;
  letter-spacing: 2px;
}

.login-input:focus {
  border-color: var(--primary);
  background: #fff;
  box-shadow: 0 0 0 3px var(--primary-bg);
}

.login-btn {
  height: 44px;
  border: none;
  border-radius: var(--radius-md);
  background: linear-gradient(135deg, var(--primary), var(--primary-dark));
  color: #fff;
  font-size: 15px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s;
  box-shadow: 0 4px 12px rgba(255, 140, 66, 0.3);
}

.login-btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 6px 16px rgba(255, 140, 66, 0.4);
}

.login-btn:active {
  transform: translateY(0);
}

.login-error {
  color: var(--danger);
  font-size: 13px;
  background: var(--danger-bg);
  padding: 8px 12px;
  border-radius: var(--radius-sm);
}

.login-tip {
  margin-top: 20px;
  font-size: 12px;
  color: var(--text-4);
}

.login-footer {
  position: relative;
  z-index: 1;
  margin-top: 32px;
  color: rgba(255, 255, 255, 0.8);
  font-size: 12px;
}

/* ============ 主应用布局 ============ */
.app {
  display: flex;
  min-height: 100vh;
}

/* ===== 侧边栏 ===== */
.sidebar {
  width: var(--sidebar-width);
  background: #fff;
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  z-index: 100;
  transition: width 0.25s ease;
}

.sidebar-header {
  height: var(--topbar-height);
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 20px;
  border-bottom: 1px solid var(--border-light);
  position: relative;
}

.sidebar-title {
  font-size: 16px;
  font-weight: 700;
  color: var(--text-1);
  letter-spacing: -0.3px;
}

.sidebar-title .brand-nami {
  background: linear-gradient(135deg, #FF8C42, #FFB37A);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  font-weight: 800;
}

.sidebar-badge {
  position: absolute;
  right: 20px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 10px;
  color: #999;
  border: 1px solid #e8e8e8;
  padding: 2px 6px;
  border-radius: 3px;
  font-weight: 500;
  letter-spacing: 0.5px;
}

.menu {
  flex: 1;
  padding: 14px 12px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  overflow-y: auto;
}

.menu-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
  border-radius: var(--radius-md);
  color: var(--text-2);
  cursor: pointer;
  transition: all 0.15s;
  position: relative;
  user-select: none;
}

.menu-item:hover {
  background: var(--primary-bg);
  color: var(--primary-dark);
}

.menu-item.active {
  background: linear-gradient(135deg, var(--primary), var(--primary-dark));
  color: #fff;
  box-shadow: 0 4px 10px rgba(255, 140, 66, 0.3);
}

.menu-icon {
  width: 20px;
  text-align: center;
  font-size: 16px;
  flex-shrink: 0;
}

.menu-badge {
  margin-left: auto;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  border-radius: 9px;
  background: var(--danger);
  color: #fff;
  font-size: 11px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
}

.menu-item.active .menu-badge {
  background: rgba(255, 255, 255, 0.3);
}

.sidebar-footer {
  padding: 12px;
  border-top: 1px solid var(--border-light);
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.sidebar-action {
  width: 100%;
  height: 36px;
  border: none;
  background: var(--bg-hover);
  border-radius: var(--radius-md);
  color: var(--text-2);
  cursor: pointer;
  font-size: 13px;
  transition: all 0.15s;
  text-align: left;
  padding: 0 14px;
}

.sidebar-action:hover {
  background: var(--primary-bg);
  color: var(--primary-dark);
}

.sidebar-action.danger:hover {
  background: var(--danger-bg);
  color: var(--danger);
}

/* ===== 主内容区 ===== */
.main {
  flex: 1;
  margin-left: var(--sidebar-width);
  display: flex;
  flex-direction: column;
  min-width: 0;
  transition: margin-left 0.25s ease;
}

/* ===== 顶部栏 ===== */
.topbar {
  height: var(--topbar-height);
  background: #fff;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  position: sticky;
  top: 0;
  z-index: 50;
}

.topbar-left {
  display: flex;
  align-items: center;
  gap: 14px;
}

.topbar-left h2 {
  font-size: 18px;
  font-weight: 600;
  color: var(--text-1);
}

.icon-btn {
  width: 34px;
  height: 34px;
  border: none;
  background: var(--bg-hover);
  border-radius: var(--radius-md);
  color: var(--text-2);
  cursor: pointer;
  font-size: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s;
}

.icon-btn:hover {
  background: var(--primary-bg);
  color: var(--primary-dark);
}

.topbar-right {
  display: flex;
  align-items: center;
  gap: 16px;
}

.topbar-env {
  font-size: 12px;
  color: var(--text-3);
  padding: 5px 10px;
  background: var(--bg-hover);
  border-radius: 12px;
  display: flex;
  align-items: center;
  gap: 6px;
}

.topbar-env::before {
  content: '';
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--text-4);
}

.topbar-env.online::before {
  background: var(--success);
  box-shadow: 0 0 0 3px var(--success-bg);
}

.topbar-env.offline::before {
  background: var(--danger);
}

.topbar-time {
  font-size: 13px;
  color: var(--text-3);
  font-variant-numeric: tabular-nums;
}

/* ===== 内容区 ===== */
.content {
  flex: 1;
  padding: 24px;
  overflow-y: auto;
}

.view {
  animation: fadeIn 0.25s ease;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ============ 工作台 ============ */
.stat-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
  margin-bottom: 20px;
}

.stat-card {
  background: var(--bg-card);
  border-radius: var(--radius-lg);
  padding: 20px;
  display: flex;
  align-items: center;
  gap: 16px;
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--border-light);
  transition: all 0.2s;
}

.stat-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}

.stat-icon {
  width: 52px;
  height: 52px;
  border-radius: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 24px;
  color: #fff;
  flex-shrink: 0;
}

.stat-orange .stat-icon { background: linear-gradient(135deg, #FF8C42, #F2731A); }
.stat-blue .stat-icon { background: linear-gradient(135deg, #5B9CFF, #2D7BF4); }
.stat-green .stat-icon { background: linear-gradient(135deg, #5BD987, #2DBA5F); }
.stat-purple .stat-icon { background: linear-gradient(135deg, #C77DFF, #9B4DCA); }

.stat-info {
  flex: 1;
  min-width: 0;
}

.stat-num {
  font-size: 28px;
  font-weight: 700;
  color: var(--text-1);
  line-height: 1.1;
  font-variant-numeric: tabular-nums;
}

.stat-label {
  font-size: 13px;
  color: var(--text-3);
  margin-top: 4px;
}

.dashboard-panels {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  margin-bottom: 16px;
}

.panel {
  background: var(--bg-card);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--border-light);
  overflow: hidden;
  margin-bottom: 16px;
}

.panel-header {
  padding: 16px 20px;
  border-bottom: 1px solid var(--border-light);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.panel-header h3 {
  font-size: 15px;
  font-weight: 600;
  color: var(--text-1);
}

.panel-link {
  font-size: 13px;
  color: var(--primary);
  cursor: pointer;
}

.panel-link:hover {
  color: var(--primary-dark);
}

.panel-body {
  padding: 8px 0;
  max-height: 320px;
  overflow-y: auto;
}

.empty-inline {
  padding: 24px;
  text-align: center;
  color: var(--text-4);
  font-size: 13px;
}

/* 工作台列表项 */
.mini-item {
  display: flex;
  align-items: center;
  padding: 10px 20px;
  gap: 12px;
  border-bottom: 1px solid var(--border-light);
  transition: background 0.15s;
}

.mini-item:last-child {
  border-bottom: none;
}

.mini-item:hover {
  background: var(--bg-hover);
}

.mini-item-main {
  flex: 1;
  min-width: 0;
}

.mini-item-title {
  font-size: 13px;
  color: var(--text-1);
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.mini-item-sub {
  font-size: 12px;
  color: var(--text-3);
  margin-top: 2px;
}

.mini-item-time {
  font-size: 12px;
  color: var(--text-4);
  flex-shrink: 0;
}

/* ============ 视图工具栏 ============ */
.view-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}

.search-box {
  flex: 1;
  min-width: 240px;
  max-width: 360px;
}

.search-box input {
  width: 100%;
  height: 38px;
  padding: 0 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: #fff;
  transition: all 0.15s;
}

.search-box input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-bg);
}

.filter-group {
  display: flex;
  align-items: center;
  gap: 8px;
}

.select {
  height: 38px;
  padding: 0 30px 0 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: #fff url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%238A8A8A' stroke-width='2'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E") no-repeat right 10px center;
  appearance: none;
  cursor: pointer;
  min-width: 120px;
}

.select:focus {
  border-color: var(--primary);
}

/* ============ 按钮 ============ */
.btn {
  height: 38px;
  padding: 0 16px;
  border: none;
  border-radius: var(--radius-md);
  cursor: pointer;
  font-size: 13px;
  font-weight: 500;
  transition: all 0.15s;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  white-space: nowrap;
}

.btn-primary {
  background: var(--primary);
  color: #fff;
}

.btn-primary:hover {
  background: var(--primary-dark);
}

.btn-ghost {
  background: #fff;
  color: var(--text-2);
  border: 1px solid var(--border);
}

.btn-ghost:hover {
  background: var(--bg-hover);
  color: var(--text-1);
}

.btn-sm {
  height: 30px;
  padding: 0 10px;
  font-size: 12px;
  border-radius: var(--radius-sm);
}

.btn-danger {
  background: #fff;
  color: var(--danger);
  border: 1px solid var(--danger);
}

.btn-danger:hover {
  background: var(--danger);
  color: #fff;
}

.btn-success {
  background: var(--success);
  color: #fff;
}

/* ============ 数据表格 ============ */
.table-wrap {
  background: var(--bg-card);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--border-light);
  overflow: hidden;
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

.data-table thead {
  background: #FAFBFC;
}

.data-table th {
  text-align: left;
  padding: 12px 14px;
  font-weight: 600;
  color: var(--text-2);
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
  font-size: 12px;
  letter-spacing: 0.3px;
}

.data-table td {
  padding: 12px 14px;
  border-bottom: 1px solid var(--border-light);
  color: var(--text-1);
  vertical-align: middle;
}

.data-table tbody tr {
  transition: background 0.12s;
}

.data-table tbody tr:hover {
  background: var(--bg-hover);
}

.data-table tbody tr:last-child td {
  border-bottom: none;
}

.empty-row {
  text-align: center;
  color: var(--text-4);
  padding: 40px 14px !important;
}

/* 表格内操作按钮组 */
.row-actions {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

/* 状态标签 */
.tag {
  display: inline-flex;
  align-items: center;
  padding: 2px 10px;
  border-radius: 11px;
  font-size: 12px;
  font-weight: 500;
  white-space: nowrap;
}

.tag-orange { background: var(--primary-bg); color: var(--primary-dark); }
.tag-green { background: var(--success-bg); color: var(--success); }
.tag-blue { background: var(--info-bg); color: var(--info); }
.tag-red { background: var(--danger-bg); color: var(--danger); }
.tag-gray { background: #F0F1F3; color: var(--text-3); }
.tag-yellow { background: var(--warning-bg); color: var(--warning); }
.tag-purple { background: var(--purple-bg); color: var(--purple); }

/* 手机号链接 */
.phone-link {
  color: var(--primary);
  font-weight: 500;
  cursor: pointer;
}

.phone-link:hover {
  text-decoration: underline;
}

/* 备注数量徽标 */
.note-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  color: var(--text-3);
  font-size: 12px;
  margin-top: 4px;
  cursor: pointer;
}

.note-badge:hover {
  color: var(--primary);
}

/* ============ 在线消息布局 ============ */
.msg-layout {
  display: flex;
  background: var(--bg-card);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--border-light);
  height: calc(100vh - var(--topbar-height) - 72px);
  overflow: hidden;
}

.msg-sidebar {
  width: 280px;
  border-right: 1px solid var(--border-light);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
}

.msg-sidebar-header {
  padding: 12px;
  border-bottom: 1px solid var(--border-light);
}

.msg-sidebar-header input {
  width: 100%;
  height: 36px;
  padding: 0 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--bg-hover);
}

.msg-sidebar-header input:focus {
  background: #fff;
  border-color: var(--primary);
}

.msg-list {
  flex: 1;
  overflow-y: auto;
}

.msg-conv {
  padding: 12px 14px;
  border-bottom: 1px solid var(--border-light);
  cursor: pointer;
  transition: background 0.12s;
  position: relative;
}

.msg-conv:hover {
  background: var(--bg-hover);
}

.msg-conv.active {
  background: var(--primary-bg);
}

.msg-conv.active::before {
  content: '';
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 3px;
  background: var(--primary);
}

.msg-conv-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 4px;
}

.msg-conv-name {
  font-size: 14px;
  font-weight: 500;
  color: var(--text-1);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.msg-conv-time {
  font-size: 11px;
  color: var(--text-4);
  flex-shrink: 0;
  margin-left: 8px;
}

.msg-conv-preview {
  font-size: 12px;
  color: var(--text-3);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.msg-conv-unread {
  background: var(--danger);
  color: #fff;
  font-size: 11px;
  min-width: 18px;
  height: 18px;
  border-radius: 9px;
  padding: 0 5px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
  margin-left: 8px;
}

/* 聊天窗 */
.msg-chat {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
  background: #FAFBFC;
}

.msg-chat-header {
  padding: 14px 20px;
  border-bottom: 1px solid var(--border-light);
  background: #fff;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.msg-chat-header-info {
  display: flex;
  flex-direction: column;
}

.msg-chat-title {
  font-size: 15px;
  font-weight: 600;
  color: var(--text-1);
}

.msg-chat-sub {
  font-size: 12px;
  color: var(--text-3);
  margin-top: 2px;
}

.msg-chat-body {
  flex: 1;
  overflow-y: auto;
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.msg-bubble-row {
  display: flex;
  gap: 10px;
  max-width: 75%;
}

.msg-bubble-row.staff {
  align-self: flex-end;
  flex-direction: row-reverse;
}

.msg-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  color: #fff;
  font-weight: 600;
}

.msg-bubble-row.user .msg-avatar {
  background: linear-gradient(135deg, #5B9CFF, #2D7BF4);
}

.msg-bubble-row.staff .msg-avatar {
  background: linear-gradient(135deg, var(--primary), var(--primary-dark));
}

.msg-bubble-content {
  display: flex;
  flex-direction: column;
}

.msg-bubble-row.staff .msg-bubble-content {
  align-items: flex-end;
}

.msg-bubble {
  padding: 10px 14px;
  border-radius: 14px;
  font-size: 14px;
  line-height: 1.5;
  word-break: break-word;
  white-space: pre-wrap;
}

.msg-bubble-row.user .msg-bubble {
  background: #fff;
  color: var(--text-1);
  border-bottom-left-radius: 4px;
  border: 1px solid var(--border-light);
}

.msg-bubble-row.staff .msg-bubble {
  background: linear-gradient(135deg, var(--primary), var(--primary-dark));
  color: #fff;
  border-bottom-right-radius: 4px;
}

.msg-bubble-time {
  font-size: 11px;
  color: var(--text-4);
  margin-top: 4px;
  padding: 0 4px;
}

.msg-chat-footer {
  padding: 14px 20px;
  border-top: 1px solid var(--border-light);
  background: #fff;
  display: flex;
  gap: 10px;
  align-items: flex-end;
}

.msg-input {
  flex: 1;
  min-height: 40px;
  max-height: 120px;
  padding: 10px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  resize: none;
  font-family: inherit;
  background: var(--bg-hover);
  transition: all 0.15s;
}

.msg-input:focus {
  background: #fff;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-bg);
}

.msg-chat-empty {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  color: var(--text-4);
}

.msg-chat-empty-icon {
  font-size: 48px;
  margin-bottom: 14px;
  opacity: 0.4;
}

/* ============ 弹窗 ============ */
.modal-mask {
  position: fixed;
  inset: 0;
  background: rgba(20, 26, 38, 0.45);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: 20px;
  animation: maskFade 0.2s ease;
}

@keyframes maskFade {
  from { opacity: 0; }
  to { opacity: 1; }
}

.modal {
  background: #fff;
  border-radius: var(--radius-lg);
  width: 100%;
  max-width: 520px;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.2);
  animation: modalSlide 0.25s ease;
}

@keyframes modalSlide {
  from { opacity: 0; transform: translateY(20px) scale(0.98); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

.modal.modal-lg {
  max-width: 720px;
}

.modal-header {
  padding: 16px 20px;
  border-bottom: 1px solid var(--border-light);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.modal-header h3 {
  font-size: 16px;
  font-weight: 600;
  color: var(--text-1);
}

.modal-close {
  width: 30px;
  height: 30px;
  border: none;
  background: var(--bg-hover);
  border-radius: 50%;
  font-size: 20px;
  color: var(--text-3);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
  transition: all 0.15s;
}

.modal-close:hover {
  background: var(--danger-bg);
  color: var(--danger);
}

.modal-body {
  padding: 20px;
  overflow-y: auto;
  flex: 1;
}

.modal-footer {
  padding: 14px 20px;
  border-top: 1px solid var(--border-light);
  display: flex;
  justify-content: flex-end;
  gap: 10px;
}

/* ============ 表单 ============ */
.form-group {
  margin-bottom: 16px;
}

.form-label {
  display: block;
  font-size: 13px;
  color: var(--text-2);
  margin-bottom: 6px;
  font-weight: 500;
}

.form-label .required {
  color: var(--danger);
  margin-left: 2px;
}

.form-input,
.form-textarea,
.form-select {
  width: 100%;
  height: 38px;
  padding: 0 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: #fff;
  transition: all 0.15s;
}

.form-textarea {
  height: auto;
  min-height: 80px;
  padding: 10px 12px;
  resize: vertical;
  font-family: inherit;
}

.form-input:focus,
.form-textarea:focus,
.form-select:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-bg);
}

.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}

/* 多选标签 */
.tag-picker {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.tag-option {
  padding: 5px 14px;
  border: 1px solid var(--border);
  border-radius: 14px;
  font-size: 13px;
  color: var(--text-2);
  cursor: pointer;
  transition: all 0.15s;
  user-select: none;
}

.tag-option:hover {
  border-color: var(--primary);
  color: var(--primary);
}

.tag-option.selected {
  background: var(--primary);
  border-color: var(--primary);
  color: #fff;
}

/* 条件列表（可增删） */
.cond-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.cond-row {
  display: flex;
  gap: 8px;
  align-items: center;
}

.cond-row .form-input {
  flex: 1;
}

/* AI 智能识别填入区 */
.ai-parse-box {
  background: linear-gradient(135deg, #FFF7ED, #FFFBF5);
  border: 1px solid #FFD9B0;
  padding: 14px;
  margin-bottom: 16px;
}
.ai-parse-title {
  font-size: 14px;
  font-weight: 600;
  color: #E8813D;
  margin-bottom: 10px;
}
.ai-parse-row {
  display: flex;
  gap: 8px;
  align-items: center;
}
.ai-parse-row .form-input {
  flex: 1;
}
.ai-parse-tip {
  margin-top: 8px;
  font-size: 12px;
  color: #999;
  line-height: 1.5;
}
.ai-parse-tip.ai-parse-loading {
  color: #E8813D;
}
.ai-parse-tip.ai-parse-success {
  color: #52C41A;
}
.ai-parse-tip.ai-parse-error {
  color: #f5222d;
}

/* AI 填充字段橙色边框标记 */
.form-input.ai-filled,
.form-select.ai-filled,
.form-textarea.ai-filled,
.tag-option.ai-filled,
.cond-input.ai-filled {
  border-color: #FF9A56 !important;
  background-color: #FFF7ED !important;
  box-shadow: 0 0 0 1px rgba(255, 154, 86, 0.3);
}
.tag-option.ai-filled.selected {
  background: linear-gradient(135deg, #FF9A56, #FFB37A) !important;
  color: #fff !important;
  border-color: #FF9A56 !important;
}

.cond-add-btn {
  align-self: flex-start;
  font-size: 13px;
  color: var(--primary);
  cursor: pointer;
  background: none;
  border: none;
  padding: 4px 0;
}

.cond-add-btn:hover {
  color: var(--primary-dark);
}

/* 备注时间线 */
.note-timeline {
  max-height: 240px;
  overflow-y: auto;
  padding: 4px 0;
}

.note-item {
  padding: 10px 12px;
  background: var(--bg-hover);
  border-radius: var(--radius-md);
  margin-bottom: 8px;
  border-left: 3px solid var(--primary);
}

.note-item:last-child {
  margin-bottom: 0;
}

.note-meta {
  display: flex;
  justify-content: space-between;
  font-size: 12px;
  color: var(--text-3);
  margin-bottom: 4px;
}

.note-content {
  font-size: 13px;
  color: var(--text-1);
  line-height: 1.5;
  white-space: pre-wrap;
}

.note-empty {
  text-align: center;
  color: var(--text-4);
  font-size: 13px;
  padding: 20px 0;
}

/* ============ Toast ============ */
.toast {
  position: fixed;
  top: 24px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(20, 26, 38, 0.92);
  color: #fff;
  padding: 10px 20px;
  border-radius: var(--radius-md);
  font-size: 14px;
  z-index: 2000;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.2);
  animation: toastSlide 0.25s ease;
  display: flex;
  align-items: center;
  gap: 8px;
  max-width: 80%;
}

.toast.success { background: var(--success); }
.toast.error { background: var(--danger); }
.toast.warning { background: var(--warning); }

@keyframes toastSlide {
  from { opacity: 0; transform: translate(-50%, -12px); }
  to { opacity: 1; transform: translate(-50%, 0); }
}

/* ============ 通用工具类 ============ */
.text-muted {
  color: var(--text-4) !important;
}

.btn-full {
  width: 100%;
}

/* ============ 客户列（头像+昵称） ============ */
.lead-customer {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.lead-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  object-fit: cover;
  flex-shrink: 0;
  background: var(--primary-bg);
  border: 1px solid var(--border-light);
}

.lead-avatar.lead-avatar-ph {
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--primary-dark);
  font-weight: 600;
  font-size: 14px;
  background: linear-gradient(135deg, var(--primary-bg), var(--primary-bg-hover));
}

.lead-customer-info {
  flex: 1;
  min-width: 0;
}

.lead-nick {
  font-size: 13px;
  font-weight: 500;
  color: var(--text-1);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.lead-sub {
  font-size: 11px;
  color: var(--text-4);
  margin-top: 2px;
}

/* ============ 会员管理（占位） ============ */
.membership-placeholder {
  background: var(--bg-card);
  border-radius: var(--radius-lg);
  border: 1px solid var(--border-light);
  box-shadow: var(--shadow-sm);
  padding: 48px 32px 40px;
  text-align: center;
}

.membership-ph-icon {
  width: 72px;
  height: 72px;
  margin: 0 auto 16px;
  border-radius: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 32px;
  background: linear-gradient(135deg, #FFE48A 0%, #FF8C42 50%, #9B4DCA 100%);
  color: #fff;
  box-shadow: 0 8px 20px rgba(255, 140, 66, 0.35);
}

.membership-ph-title {
  font-size: 24px;
  font-weight: 600;
  color: var(--text-1);
  margin-bottom: 8px;
}

.membership-ph-sub {
  font-size: 14px;
  color: var(--text-3);
  margin-bottom: 32px;
}

.membership-ph-cards {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 20px;
  max-width: 960px;
  margin: 0 auto 28px;
}

.membership-ph-card {
  border-radius: 16px;
  padding: 24px 20px;
  border: 2px solid var(--border);
  background: #fff;
  display: flex;
  flex-direction: column;
  gap: 16px;
  transition: all 0.2s;
  position: relative;
  overflow: hidden;
}

.membership-ph-card.bronze {
  border-color: #D7A05C;
  background: linear-gradient(180deg, #FFF8EE 0%, #FFFFFF 60%);
}

.membership-ph-card.silver {
  border-color: #8FA3B8;
  background: linear-gradient(180deg, #F2F6FB 0%, #FFFFFF 60%);
}

.membership-ph-card.gold {
  border-color: #E5B637;
  background: linear-gradient(180deg, #FFFAE8 0%, #FFFFFF 60%);
  transform: translateY(-6px);
  box-shadow: 0 12px 28px rgba(229, 182, 55, 0.2);
}

.membership-card-badge {
  align-self: flex-start;
  padding: 4px 12px;
  border-radius: 12px;
  font-size: 12px;
  font-weight: 600;
}

.membership-ph-card.bronze .membership-card-badge {
  background: #F4E2C8;
  color: #8C5E1E;
}

.membership-ph-card.silver .membership-card-badge {
  background: #DEE7F0;
  color: #3F5771;
}

.membership-ph-card.gold .membership-card-badge {
  background: #F5E3A7;
  color: #8A6A0A;
}

.membership-card-price {
  display: flex;
  align-items: baseline;
  gap: 2px;
  color: var(--text-1);
}

.membership-card-price .currency {
  font-size: 16px;
  font-weight: 600;
}

.membership-card-price .amount {
  font-size: 36px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.membership-card-price .unit {
  font-size: 13px;
  color: var(--text-3);
  margin-left: 2px;
}

.membership-card-feats {
  list-style: none;
  padding: 0;
  margin: 0;
  text-align: left;
  display: flex;
  flex-direction: column;
  gap: 8px;
  font-size: 13px;
  color: var(--text-2);
  flex: 1;
}

.membership-ph-tip {
  font-size: 12px;
  color: var(--text-4);
}

/* ============ 渠道归因与结算 ============ */

/* 菜单分组标签 */
.menu-group-label {
  padding: 12px 20px 4px;
  font-size: 11px;
  color: var(--text-4);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

/* 渠道头像 */
.channel-avatar {
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  font-weight: 600;
  color: #fff;
  flex-shrink: 0;
}
.avatar-1 { background: linear-gradient(135deg, #FF8C42, #F2731A); }
.avatar-2 { background: linear-gradient(135deg, #007AFF, #0056D2); }
.avatar-3 { background: linear-gradient(135deg, #34C759, #248A3D); }
.avatar-4 { background: linear-gradient(135deg, #AF52DE, #892CE0); }
.avatar-5 { background: linear-gradient(135deg, #FF9F0A, #CC7A00); }

/* 渠道码展示 */
.qrcode-box {
  display: flex;
  align-items: center;
  gap: 12px;
}
.qrcode-img {
  width: 48px;
  height: 48px;
  border: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  color: var(--text-3);
  flex-shrink: 0;
}
.qrcode-info {
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.qrcode-id {
  font-size: 12px;
  color: var(--text-3);
}
.qrcode-action {
  font-size: 12px;
  color: var(--primary);
  cursor: pointer;
}

/* 转化漏斗 */
.funnel {
  display: flex;
  align-items: center;
  gap: 0;
  margin: 20px 0;
}
.funnel-step {
  flex: 1;
  text-align: center;
}
.funnel-bar {
  height: 48px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 18px;
  color: #fff;
}
.funnel-bar.s1 { background: var(--primary); border-radius: 8px 0 0 8px; }
.funnel-bar.s2 { background: #FF9F5C; }
.funnel-bar.s3 { background: #FFB78A; }
.funnel-bar.s4 { background: var(--success); border-radius: 0 8px 8px 0; }
.funnel-label {
  font-size: 12px;
  color: var(--text-3);
  margin-top: 6px;
}
.funnel-arrow {
  color: var(--text-4);
  font-size: 16px;
  padding: 0 4px;
}

/* 进度条 */
.progress-bar {
  width: 100%;
  height: 6px;
  background: var(--border-light);
  border-radius: 3px;
  overflow: hidden;
}
.progress-fill {
  height: 100%;
  border-radius: 3px;
  transition: width 0.3s;
}
.progress-fill.orange { background: var(--primary); }
.progress-fill.green { background: var(--success); }
.progress-fill.blue { background: var(--info); }

/* 操作链接 */
.action-link {
  color: var(--primary);
  cursor: pointer;
  font-size: 13px;
  margin-right: 8px;
  white-space: nowrap;
}
.action-link:hover {
  color: var(--primary-dark);
}
.action-link.danger {
  color: var(--danger);
}

/* ============ 滚动条美化 ============ */
::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  background: #DCDFE5;
  border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
  background: #C0C4CC;
}

/* ============ 响应式 ============ */
@media (max-width: 1100px) {
  .stat-grid {
    grid-template-columns: repeat(2, 1fr);
  }
  .dashboard-panels {
    grid-template-columns: 1fr;
  }
  .membership-ph-cards {
    grid-template-columns: 1fr 1fr;
    max-width: 720px;
  }
  .membership-ph-card.gold {
    transform: none;
  }
}

@media (max-width: 720px) {
  .membership-ph-cards {
    grid-template-columns: 1fr;
    max-width: 400px;
  }
}

@media (max-width: 768px) {
  .sidebar {
    width: var(--sidebar-collapsed);
  }
  .sidebar-title,
  .menu-item span:not(.menu-icon):not(.menu-badge),
  .sidebar-action {
    display: none;
  }
  .menu-item {
    justify-content: center;
    padding: 12px 0;
  }
  .menu-badge {
    position: absolute;
    top: 4px;
    right: 4px;
  }
  .main {
    margin-left: var(--sidebar-collapsed);
  }
  .sidebar-footer {
    align-items: center;
  }
  .sidebar-footer .sidebar-action {
    width: 40px;
    height: 40px;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
  }
  .stat-grid {
    grid-template-columns: 1fr;
  }
  .msg-sidebar {
    width: 200px;
  }
  .form-row {
    grid-template-columns: 1fr;
  }
  .topbar-time {
    display: none;
  }
  .content {
    padding: 16px;
  }
}

/* ============ 渠道详情 Tab ============ */
.detail-tabs {
  display: flex;
  gap: 0;
  border-bottom: 2px solid var(--border-light);
  margin-bottom: 18px;
  flex-wrap: wrap;
}
.detail-tab {
  padding: 10px 18px;
  font-size: 14px;
  color: var(--text-3);
  cursor: pointer;
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
  transition: all 0.15s;
  font-weight: 500;
}
.detail-tab:hover {
  color: var(--primary);
}
.detail-tab.active {
  color: var(--primary);
  border-bottom-color: var(--primary);
}
.detail-tab-panel {
  display: none;
}
.detail-tab-panel.active {
  display: block;
}
.detail-info-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px 24px;
  margin-bottom: 16px;
}
.detail-info-item {
  font-size: 13px;
}
.detail-info-item .label {
  color: var(--text-3);
  margin-right: 8px;
}
.detail-info-item .value {
  color: var(--text-1);
  font-weight: 500;
}
.detail-section-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-1);
  margin: 18px 0 12px;
  padding-left: 8px;
  border-left: 3px solid var(--primary);
}
.commission-config-table {
  width: 100%;
  border-collapse: collapse;
  margin-bottom: 12px;
}
.commission-config-table th,
.commission-config-table td {
  padding: 10px 12px;
  text-align: left;
  border-bottom: 1px solid var(--border-light);
  font-size: 13px;
}
.commission-config-table th {
  background: var(--bg-2);
  color: var(--text-2);
  font-weight: 500;
}
.commission-config-table input[type="number"] {
  width: 80px;
  height: 32px;
  padding: 0 8px;
  border: 1px solid var(--border);
  border-radius: 6px;
  text-align: center;
}
.qr-preview-wrap {
  display: flex;
  gap: 24px;
  align-items: flex-start;
  flex-wrap: wrap;
}
.qr-preview-card {
  text-align: center;
}
.qr-preview-card img {
  width: 160px;
  height: 160px;
  border: 1px solid var(--border);
  border-radius: 12px;
  object-fit: contain;
  background: #fff;
}
.qr-preview-card .qr-placeholder {
  width: 160px;
  height: 160px;
  border: 1px dashed var(--border);
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-4);
  font-size: 13px;
  background: var(--bg-2);
}
.qr-preview-card p {
  margin-top: 8px;
  font-size: 13px;
  color: var(--text-2);
}
.share-link-box {
  display: flex;
  gap: 8px;
  align-items: center;
  background: var(--bg-2);
  padding: 10px 14px;
  margin-top: 12px;
}
.share-link-box .link-text {
  flex: 1;
  font-size: 13px;
  color: var(--text-2);
  word-break: break-all;
  font-family: monospace;
}
.detail-modal .modal-body {
  max-height: 70vh;
}

/* ============ 授权用户：备注名徽章 + 客户聚合档案 ============ */
.au-remark-badge {
  display: inline-block;
  font-size: 10px;
  padding: 1px 5px;
  border-radius: 3px;
  background: var(--primary-bg);
  color: var(--primary-dark);
  font-weight: 500;
  margin-left: 4px;
  vertical-align: middle;
}
.au-remark-badge.au-remark-warn {
  background: #FFF4E6;
  color: #CC6600;
}

/* 客户聚合档案抽屉 */
.modal-lg .agg-card {
  background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
  color: #fff;
  border-radius: 10px;
  padding: 14px 16px;
  margin-bottom: 14px;
}
.agg-id-row {
  font-size: 13px;
  margin-top: 5px;
  opacity: 0.95;
}
.agg-id-row.text-muted,
.agg-id-row .text-muted {
  opacity: 0.7;
}
.agg-id-remark {
  font-size: 17px;
  font-weight: 700;
  margin-top: 0;
  margin-bottom: 4px;
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  opacity: 1;
}
.agg-id-remark .text-muted {
  font-weight: 500;
  opacity: 0.85;
}
.agg-edit {
  font-size: 11px;
  background: rgba(255, 255, 255, 0.25);
  padding: 3px 9px;
  border-radius: 12px;
  cursor: pointer;
  font-weight: 400;
  white-space: nowrap;
}
.agg-edit:hover {
  background: rgba(255, 255, 255, 0.4);
}
.agg-edit-input {
  flex: 1;
  min-width: 200px;
  border: 1px solid #fff;
  border-radius: 5px;
  padding: 5px 9px;
  font-size: 14px;
  font-weight: 600;
  color: #1A1A2E;
  background: #fff;
  outline: none;
}
.agg-edit-save {
  font-size: 12px;
  background: #fff;
  color: var(--primary-dark);
  padding: 5px 12px;
  border-radius: 5px;
  cursor: pointer;
  border: none;
  font-weight: 600;
}
.agg-edit-cancel {
  font-size: 12px;
  background: transparent;
  color: #fff;
  padding: 5px 8px;
  border: 1px solid rgba(255, 255, 255, 0.6);
  border-radius: 5px;
  cursor: pointer;
}

.agg-tabs {
  display: flex;
  gap: 2px;
  border-bottom: 1px solid var(--border-light);
  margin-bottom: 12px;
}
.agg-tab {
  padding: 9px 12px;
  font-size: 13px;
  cursor: pointer;
  color: var(--text-3);
  border-bottom: 2px solid transparent;
  display: flex;
  align-items: center;
  gap: 5px;
}
.agg-tab:hover {
  color: var(--primary-dark);
}
.agg-tab.active {
  color: var(--primary-dark);
  border-bottom-color: var(--primary);
  font-weight: 600;
}
.agg-tab-count {
  background: var(--primary-bg);
  color: var(--primary-dark);
  padding: 0 6px;
  border-radius: 10px;
  font-size: 11px;
  font-weight: 500;
}

.agg-list {
  max-height: 320px;
  overflow-y: auto;
  padding-right: 4px;
}
.agg-record {
  padding: 10px 12px;
  background: var(--bg-hover);
  border-radius: 6px;
  margin-bottom: 8px;
  font-size: 12px;
}
.agg-record:last-child {
  margin-bottom: 0;
}
.agg-record-title {
  font-weight: 600;
  color: var(--text-1);
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}
.agg-record-meta {
  color: var(--text-3);
  margin-top: 4px;
  font-size: 11px;
}
.agg-status {
  display: inline-block;
  padding: 1px 6px;
  border-radius: 3px;
  font-size: 10px;
  font-weight: 500;
}
.agg-status.s-new {
  background: #E6F4FF;
  color: #0066CC;
}
.agg-status.s-progress {
  background: #FFF4E6;
  color: #CC6600;
}
.agg-status.s-done {
  background: #E6F7EE;
  color: #00875A;
}
.agg-status.s-warn {
  background: #FFEEEE;
  color: #CC3333;
}
.agg-loading,
.agg-empty {
  color: var(--text-3);
  font-size: 13px;
  text-align: center;
  padding: 24px 0;
}

/* ================================================
 * 政策管理子 Tab
 * ================================================ */
.sub-tabs {
  display: flex;
  background: #fff;
  border-radius: 14px;
  padding: 6px;
  box-shadow: var(--shadow-sm);
  margin-bottom: 20px;
  gap: 4px;
}
.sub-tab {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  background: transparent;
  border: none;
  border-radius: 10px;
  padding: 12px 20px;
  font-size: 14px;
  font-weight: 600;
  color: var(--text-3);
  cursor: pointer;
  transition: all .18s;
}
.sub-tab:hover { color: var(--primary-dark); }
.sub-tab.active {
  background: linear-gradient(135deg, #FF8C42 0%, #FF6B2B 100%);
  color: #fff;
  box-shadow: 0 4px 12px rgba(255, 140, 66, 0.3);
}
.sub-tab-badge {
  background: rgba(0, 0, 0, 0.15);
  color: #fff;
  padding: 2px 8px;
  border-radius: 10px;
  font-size: 12px;
  font-weight: 500;
}
.sub-tab:not(.active) .sub-tab-badge {
  background: var(--primary-bg, #FFF3EA);
  color: var(--primary-dark, #F2731A);
}

/* ================================================
 * 正式政策页头 + 统计卡
 * ================================================ */
.policy-page-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
  flex-wrap: wrap;
  gap: 12px;
}
.policy-page-head h1 {
  font-size: 22px;
  font-weight: 700;
  color: var(--text-1);
  margin: 0;
}
.policy-page-head h1 .sub {
  font-size: 13px;
  font-weight: 400;
  color: var(--text-3);
  margin-left: 10px;
}
.policy-page-head h1 .sub em {
  font-style: normal;
  font-weight: 700;
  color: var(--primary-dark);
}
.policy-head-actions {
  display: flex;
  gap: 10px;
}
.policy-stats {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
  margin-bottom: 20px;
}
.policy-stat {
  background: #fff;
  border-radius: 14px;
  padding: 18px 22px;
  box-shadow: var(--shadow-sm);
  display: flex;
  align-items: center;
  gap: 14px;
  border: 1px solid var(--border-light);
}
.policy-stat .icon {
  width: 44px;
  height: 44px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  font-weight: 700;
  letter-spacing: 1px;
  flex-shrink: 0;
}
.policy-stat .icon.orange { background: #FFF3EA; color: #F2731A; }
.policy-stat .icon.green { background: #EAF9F0; color: #2DBA5F; }
.policy-stat .icon.red { background: #FDECEC; color: #E74C3C; }
.policy-stat .info .label {
  font-size: 12px;
  color: var(--text-3);
  margin-bottom: 4px;
}
.policy-stat .info .value {
  font-size: 22px;
  font-weight: 700;
  color: var(--text-1);
  line-height: 1.1;
  font-variant-numeric: tabular-nums;
}

/* ================================================
 * 自动采集待审核 Tab
 * ================================================ */
.ingest-header {
  display: flex;
  gap: 16px;
  margin-bottom: 16px;
  align-items: stretch;
}
.ingest-stats {
  display: flex;
  gap: 12px;
  flex: 1;
}
.ingest-stat-card {
  flex: 1;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 14px 16px;
  display: flex;
  flex-direction: column;
  justify-content: center;
}
.ingest-stat-num {
  font-size: 28px;
  font-weight: 700;
  color: var(--text-1);
  line-height: 1.1;
}
.ingest-stat-label {
  font-size: 12px;
  color: var(--text-3);
  margin-top: 4px;
}
.ingest-stat-card[data-status="已归一化"] .ingest-stat-num { color: var(--primary); }
.ingest-stat-card[data-status="待下架"] .ingest-stat-num { color: #e74c3c; }
.ingest-stat-card[data-status="重复跳过"] .ingest-stat-num { color: var(--text-3); }
.ingest-stat-run {
  background: #fff7f0;
  border-color: #ffd9b3;
}
.ingest-stat-value {
  font-size: 14px;
  font-weight: 600;
  color: var(--primary);
  line-height: 1.3;
}
.ingest-header-right {
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 10px;
  min-width: 200px;
}

.ingest-filter-bar {
  display: flex;
  gap: 8px;
  align-items: center;
  margin-bottom: 14px;
  flex-wrap: wrap;
}
.ingest-chip {
  background: #f5f5f5;
  border: 1px solid transparent;
  border-radius: 20px;
  padding: 6px 14px;
  font-size: 13px;
  color: var(--text-2);
  cursor: pointer;
  transition: all .15s;
}
.ingest-chip:hover { background: #ececec; }
.ingest-chip.active {
  background: var(--primary);
  color: #fff;
}

.ingest-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.ingest-card {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 14px 16px;
  display: flex;
  position: relative;
  transition: border-color .15s, box-shadow .15s;
}
.ingest-card:hover {
  border-color: var(--primary-light, #ffd9b3);
  box-shadow: 0 2px 8px rgba(255, 140, 66, .08);
}
.ingest-card-leftbar {
  width: 4px;
  min-height: 100%;
  border-radius: 2px;
  margin-right: 12px;
  background: var(--primary);
  flex-shrink: 0;
  align-self: stretch;
  margin-top: -14px;
  margin-bottom: -14px;
  margin-left: -16px;
}
.ingest-card.st-new .ingest-card-leftbar { background: var(--primary); }
.ingest-card.st-normal .ingest-card-leftbar { background: #3498db; }
.ingest-card.st-expired .ingest-card-leftbar { background: #e74c3c; }
.ingest-card.st-skipped .ingest-card-leftbar { background: #bbb; }
.ingest-card.st-published .ingest-card-leftbar { background: #27ae60; }
.ingest-card.st-expired { background: #fdf5f5; }
.ingest-card.st-skipped, .ingest-card.st-published { background: #fafafa; opacity: .85; }

.ingest-card-body {
  flex: 1;
  min-width: 0;
}
.ingest-card-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 10px;
  margin-bottom: 6px;
}
.ingest-card-title-wrap {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
  flex: 1;
  min-width: 0;
}
.ingest-card-title {
  font-size: 15px;
  font-weight: 600;
  color: var(--text-1);
  text-decoration: none;
  line-height: 1.35;
  cursor: pointer;
}
.ingest-card-title:hover { color: var(--primary); text-decoration: underline; }
.ingest-card-status {
  font-size: 12px;
  color: var(--text-3);
  white-space: nowrap;
  flex-shrink: 0;
}
.ingest-card-summary {
  font-size: 13px;
  color: var(--text-2);
  line-height: 1.5;
  margin-bottom: 6px;
}
.ingest-card-meta {
  display: flex;
  gap: 14px;
  font-size: 12px;
  color: var(--text-3);
  flex-wrap: wrap;
  margin-bottom: 10px;
}
.ingest-card-actions {
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.ingest-link {
  font-size: 12px;
  color: var(--primary);
  text-decoration: none;
}
.ingest-link:hover { text-decoration: underline; }
.ingest-card-actions-right {
  display: flex;
  gap: 8px;
  align-items: center;
}
.ingest-published-tag, .ingest-skipped-tag {
  font-size: 12px;
  color: var(--text-3);
}

/* ================================================
 * 采集设置 Tab
 * ================================================ */
.settings-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 16px;
}
.settings-card {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 18px 20px;
}
.settings-card h4 {
  margin: 0 0 6px 0;
  font-size: 14px;
  font-weight: 600;
  color: var(--text-1);
}
.settings-desc {
  margin: 0 0 14px 0;
  font-size: 12px;
  color: var(--text-3);
  line-height: 1.6;
}
.settings-row {
  display: flex;
  gap: 10px;
  align-items: center;
  padding: 6px 0;
  font-size: 13px;
  color: var(--text-2);
}
.settings-row > span:first-child {
  width: 84px;
  flex-shrink: 0;
  color: var(--text-3);
}
.settings-row code {
  background: #f5f5f5;
  padding: 2px 6px;
  border-radius: 4px;
  font-size: 12px;
}
.field-map-table {
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
}
.field-map-head {
  display: grid;
  grid-template-columns: 140px 1fr;
  background: #fafafa;
  padding: 8px 12px;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-2);
  border-bottom: 1px solid var(--border);
}
.field-map-row {
  display: grid;
  grid-template-columns: 140px 1fr;
  padding: 7px 12px;
  font-size: 12px;
  border-bottom: 1px solid #f0f0f0;
  gap: 8px;
}
.field-map-row:last-child { border-bottom: none; }
.field-map-row code {
  background: #fff4ec;
  color: var(--primary);
  padding: 1px 6px;
  border-radius: 3px;
  font-size: 12px;
}

/* 采集来源网格 */
.source-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px;
  max-height: 340px;
  overflow-y: auto;
}
.source-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  background: #fafafa;
  border: 1px solid #f0f0f0;
  border-radius: 8px;
}
.source-block {
  width: 28px;
  height: 28px;
  background: var(--primary);
  color: #fff;
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  font-weight: 600;
  flex-shrink: 0;
}
.source-info {
  flex: 1;
  min-width: 0;
}
.source-name {
  font-size: 13px;
  font-weight: 500;
  color: var(--text-1);
  line-height: 1.2;
}
.source-code {
  font-size: 11px;
  color: var(--text-3);
  margin-top: 2px;
}

/* bb */