/* ============================================
   SPLIT LAYOUT - 分栏布局共用样式（logs + templates）
   ============================================ */

/* Split layout container */
.split-layout {
  display: flex;
  gap: 0;
  height: calc(100vh - 120px);
  background: var(--bg-white);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--border-light);
  overflow: hidden;
}

/* Left panel - list */
.split-list-panel {
  flex: 0 0 400px;
  display: flex;
  flex-direction: column;
  border-right: 1px solid var(--border-light);
  background: var(--bg-white);
  min-width: 0;
}

.split-list-panel-inner {
  display: flex;
  flex-direction: column;
  height: 100%;
  overflow: hidden;
}

/* Right panel - detail/preview */
.split-detail-panel {
  flex: 1;
  display: flex;
  flex-direction: column;
  background: linear-gradient(168deg, #fafbff 0%, #f4f6fc 40%, #f0f2fa 100%);
  overflow: auto;
  position: relative;
}

.split-detail-panel::before {
  content: '';
  position: absolute;
  top: 0;
  right: 0;
  width: 280px;
  height: 280px;
  background: radial-gradient(circle, rgba(67, 97, 238, 0.04) 0%, transparent 70%);
  pointer-events: none;
}

/* Toolbar */
.split-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 20px;
  gap: 12px;
  flex-shrink: 0;
  border-bottom: 1px solid var(--border-light);
  background: var(--bg-white);
}

.split-toolbar-left {
  display: flex;
  align-items: baseline;
  gap: 8px;
}

.split-title {
  font-size: 17px;
  font-weight: 700;
  color: var(--text);
  letter-spacing: -0.02em;
}

.split-count {
  font-size: 12px;
  color: var(--text-tertiary);
  font-weight: 500;
  background: var(--gray-100);
  padding: 2px 8px;
  border-radius: 10px;
}

.split-toolbar-right {
  display: flex;
  align-items: center;
  gap: 8px;
}

/* List */
.split-list {
  flex: 1;
  overflow-y: auto;
  padding: 0;
}

/* Empty state */
.split-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 60px 24px;
  text-align: center;
  flex: 1;
}

.split-empty svg {
  width: 44px;
  height: 44px;
  color: var(--gray-300);
  margin-bottom: 14px;
}

.split-empty h3 {
  font-size: 15px;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 4px;
}

.split-empty p {
  font-size: 13px;
  color: var(--text-tertiary);
}

/* Placeholder */
.split-detail-placeholder {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 100%;
  text-align: center;
  padding: 40px;
  animation: fadeIn 0.4s ease;
}

.split-detail-placeholder-icon {
  width: 80px;
  height: 80px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--primary-light) 0%, #e8ecff 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 20px;
  box-shadow: 0 4px 20px rgba(67, 97, 238, 0.08);
}

.split-detail-placeholder-icon svg {
  width: 36px;
  height: 36px;
  color: var(--primary);
  opacity: 0.7;
}

.split-detail-placeholder h3 {
  font-size: 16px;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 6px;
}

.split-detail-placeholder p {
  font-size: 13px;
  color: var(--text-tertiary);
}

/* Detail content (shared animation) */
.split-detail-content {
  animation: slideInRight 0.3s ease;
}

@keyframes slideInRight {
  from {
    opacity: 0;
    transform: translateX(12px);
  }
  to {
    opacity: 1;
    transform: translateX(0);
  }
}

/* Three-dot menu (shared) */
.split-item-menu {
  position: relative;
}

.split-menu-trigger {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 26px;
  height: 26px;
  border-radius: var(--radius-xs);
  border: none;
  background: none;
  cursor: pointer;
  color: var(--text-tertiary);
  transition: all var(--transition-fast);
}

.split-menu-trigger:hover {
  background: var(--gray-100);
  color: var(--text-secondary);
}

.split-menu-trigger svg {
  width: 15px;
  height: 15px;
}

.split-menu-dropdown {
  position: absolute;
  top: 100%;
  right: 0;
  background: var(--bg-white);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-lg);
  min-width: 140px;
  z-index: 100;
  display: none;
  padding: 4px 0;
}

.split-menu-dropdown.active {
  display: block;
}

.split-menu-item {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding: 8px 14px;
  border: none;
  background: none;
  cursor: pointer;
  font-size: 13px;
  font-family: var(--font-sans);
  color: var(--text-secondary);
  transition: all var(--transition-fast);
  text-align: left;
}

.split-menu-item:hover {
  background: var(--primary-subtle);
  color: var(--primary);
}

.split-menu-item.danger:hover {
  background: var(--danger-light);
  color: var(--danger);
}

.split-menu-item svg {
  width: 14px;
  height: 14px;
  flex-shrink: 0;
}

/* ============================================
   LOGS PAGE - 发送记录（独有样式）
   精致现代风：卡片式列表 + 分区详情 + 移动端 Sheet
   ============================================ */

/* ---- 主布局容器 ---- */
.logs-layout {
  display: flex;
  gap: 0;
  height: calc(100vh - 120px);
  background: var(--bg-white);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--border-light);
  overflow: hidden;
}

/* ---- 左侧列表面板 ---- */
.logs-list-panel {
  flex: 0 0 400px;
  display: flex;
  flex-direction: column;
  border-right: 1px solid var(--border-light);
  background: var(--bg-white);
  min-width: 0;
}

.logs-list-panel-inner {
  display: flex;
  flex-direction: column;
  height: 100%;
  overflow: hidden;
}

/* ---- 顶部工具栏 ---- */
.logs-toolbar {
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  background: var(--bg-white);
  border-bottom: 1px solid var(--border-light);
}

.logs-toolbar-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px 12px;
  gap: 12px;
}

.logs-toolbar-title-group {
  display: flex;
  align-items: baseline;
  gap: 10px;
}

.logs-toolbar-title {
  font-size: 17px;
  font-weight: 700;
  color: var(--text);
  letter-spacing: -0.02em;
}

.logs-toolbar-count {
  font-size: 11.5px;
  color: var(--text-secondary);
  font-weight: 600;
  background: var(--gray-100);
  padding: 2px 9px;
  border-radius: 10px;
  letter-spacing: 0.01em;
}

.logs-toolbar-actions {
  display: flex;
  align-items: center;
  gap: 6px;
}

/* ---- 操作按钮 ---- */
.logs-action-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  height: 30px;
  padding: 0 12px;
  border-radius: 8px;
  font-size: 12.5px;
  font-weight: 600;
  font-family: var(--font-sans);
  color: var(--text-secondary);
  background: var(--bg-subtle);
  border: 1px solid transparent;
  cursor: pointer;
  transition: all var(--transition-fast);
  letter-spacing: 0.01em;
}

.logs-action-btn svg {
  width: 14px;
  height: 14px;
  flex-shrink: 0;
}

.logs-action-btn:hover:not(:disabled) {
  background: var(--primary-light);
  color: var(--primary);
}

.logs-action-btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.logs-action-btn.icon-only {
  width: 30px;
  padding: 0;
}

.logs-action-btn.danger:hover:not(:disabled) {
  background: var(--danger-light);
  color: var(--danger);
}

/* ---- 同步状态提示 ---- */
.logs-sync-status {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 20px;
  font-size: 12.5px;
  color: var(--primary);
  background: var(--primary-subtle);
  border-bottom: 1px solid var(--border-light);
  animation: slideDown 0.2s ease-out;
}

.logs-sync-status svg {
  width: 14px;
  height: 14px;
  flex-shrink: 0;
}

.logs-sync-spin {
  animation: logs-sync-rotate 0.8s linear infinite;
}

@keyframes logs-sync-rotate {
  to { transform: rotate(360deg); }
}

@keyframes slideDown {
  from { opacity: 0; transform: translateY(-4px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ---- 筛选标签栏（分段控件） ---- */
.logs-filter-bar {
  display: flex;
  gap: 2px;
  padding: 10px 20px 14px;
  flex-shrink: 0;
}

.logs-filter-tab {
  padding: 6px 14px;
  border: none;
  background: transparent;
  border-radius: 8px;
  font-size: 12.5px;
  font-weight: 500;
  font-family: var(--font-sans);
  color: var(--text-secondary);
  cursor: pointer;
  transition: all 150ms ease-out;
  white-space: nowrap;
  position: relative;
}

.logs-filter-tab:hover {
  color: var(--text);
  background: var(--gray-100);
}

.logs-filter-tab.active {
  background: var(--primary);
  color: var(--text-inverse);
  font-weight: 600;
  box-shadow: 0 1px 3px rgba(67, 97, 238, 0.25);
}

/* ---- 批量选择栏 ---- */
.logs-select-bar {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 20px;
  background: var(--primary-subtle);
  border-bottom: 1px solid var(--border-light);
  animation: slideDown 0.2s ease-out;
  flex-shrink: 0;
}

.logs-select-all-label {
  display: flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
}

.logs-select-all-label input[type="checkbox"] {
  accent-color: var(--primary);
  width: 15px;
  height: 15px;
  cursor: pointer;
}

.logs-selected-count {
  font-size: 12px;
  color: var(--text-secondary);
  font-weight: 500;
}

/* ---- 记录列表容器 ---- */
.logs-list {
  /* 按内容自适应高度，内容多时受父容器约束滚动，内容少时不撑出空白 */
  flex: 0 1 auto;
  overflow-y: auto;
  padding: 12px 14px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-height: 0;
}

/* ---- 列表项（卡片式） ---- */
.email-log-item {
  padding: 14px 16px;
  border-radius: var(--radius-md);
  background: var(--bg-white);
  border: 1px solid var(--border-light);
  transition: all var(--transition-fast);
  position: relative;
  cursor: pointer;
}

.email-log-item:hover {
  border-color: var(--gray-300);
  box-shadow: var(--shadow-sm);
  transform: translateY(-1px);
}

.email-log-item.active {
  background: var(--primary-subtle);
  border-color: var(--primary);
  box-shadow: 0 0 0 1px var(--primary), var(--shadow-sm);
}

.email-log-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 8px;
}

.email-log-header-left {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 1;
  min-width: 0;
}

.email-log-checkbox {
  flex-shrink: 0;
  accent-color: var(--primary);
  width: 15px;
  height: 15px;
  cursor: pointer;
  display: none;
}

/* 多选模式：显示复选框 */
.logs-list-panel.multi-select-mode .email-log-checkbox {
  display: block;
}

/* 批量删除按钮默认隐藏，多选模式显示 */
#logsBatchDeleteBtn {
  display: none;
}

.logs-list-panel.multi-select-mode #logsBatchDeleteBtn,
.logs-list-panel.multi-select-mode #logsBatchBar {
  display: flex;
}

#logsBatchBar {
  display: none;
}

.email-log-subject {
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  letter-spacing: -0.01em;
}

.email-log-header-right {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}

.email-log-meta {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12.5px;
  color: var(--text-secondary);
  line-height: 1.5;
  padding-left: 23px;
  margin-top: 4px;
}

.email-log-meta + .email-log-meta {
  margin-top: 2px;
}

.email-log-meta-time {
  justify-content: space-between;
}

.email-log-meta-time > .email-log-time {
  margin-left: auto;
}

.email-log-time {
  font-size: 11.5px;
  color: var(--text-tertiary);
  font-weight: 500;
}

.email-log-more {
  color: var(--text-tertiary);
  font-weight: 500;
}

.email-log-attachments {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-top: 6px;
  padding-left: 23px;
}

/* ---- 列表项标记 ---- */
.email-log-forward-badge {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  padding: 1px 7px;
  border-radius: 4px;
  font-size: 10.5px;
  font-weight: 600;
  background: rgba(99, 102, 241, 0.1);
  color: #6366f1;
  flex-shrink: 0;
  letter-spacing: 0.02em;
}

.email-log-forward-badge svg {
  width: 10px;
  height: 10px;
}

.email-log-source-badge {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  padding: 1px 7px;
  border-radius: 4px;
  font-size: 10.5px;
  font-weight: 600;
  flex-shrink: 0;
  letter-spacing: 0.02em;
}

.email-log-source-badge svg {
  width: 10px;
  height: 10px;
}

.email-log-source-badge.local {
  background: rgba(34, 197, 94, 0.1);
  color: #16a34a;
}

.email-log-source-badge.server {
  background: rgba(59, 130, 246, 0.1);
  color: #2563eb;
}

.email-log-source-badge.api {
  background: rgba(168, 85, 247, 0.1);
  color: #7c3aed;
}

/* ---- 附件标签 ---- */
.attachment-tag {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 11px;
  font-weight: 500;
  padding: 2px 8px;
  border-radius: 10px;
  background: var(--gray-100);
  color: var(--text-secondary);
}

.attachment-tag svg {
  width: 10px;
  height: 10px;
}

/* ---- 状态标签 ---- */
.status-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 11px;
  font-weight: 600;
  padding: 3px 9px;
  border-radius: 10px;
  letter-spacing: 0.02em;
  white-space: nowrap;
}

.status-badge.success {
  background: var(--success-light);
  color: #059669;
}

.status-badge.failed {
  background: var(--danger-light);
  color: #dc2626;
}

.status-badge.pending {
  background: var(--warning-light);
  color: #d97706;
}

.status-badge.cancelled {
  background: var(--gray-100);
  color: var(--gray-500);
}

.status-badge svg {
  width: 12px;
  height: 12px;
}

.status-badge.read {
  background: #dbeafe;
  color: #2563eb;
}

.status-badge.unread {
  background: #fef3c7;
  color: #d97706;
}

.status-badge.partial-read {
  background: #e0e7ff;
  color: #4f46e5;
}

.status-badge.untrackable {
  background: var(--gray-100);
  color: var(--gray-400);
}

/* ---- 空状态 ---- */
.logs-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 60px 24px;
  text-align: center;
  flex: 1;
}

.logs-empty-icon {
  width: 64px;
  height: 64px;
  border-radius: 50%;
  background: var(--bg-subtle);
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 16px;
}

.logs-empty-icon svg {
  width: 28px;
  height: 28px;
  color: var(--gray-400);
}

.logs-empty h3 {
  font-size: 15px;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 4px;
}

.logs-empty p {
  font-size: 13px;
  color: var(--text-tertiary);
}

/* ---- 无限滚动加载状态 ---- */
.infinite-loading {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 16px 12px;
  color: var(--text-secondary);
  font-size: 13px;
  text-align: center;
}

.infinite-loading::before {
  content: '';
  display: inline-block;
  width: 14px;
  height: 14px;
  border: 2px solid var(--border);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: infinite-spin 0.8s linear infinite;
}

@keyframes infinite-spin {
  to { transform: rotate(360deg); }
}

.infinite-end {
  padding: 8px 12px 4px;
  color: var(--text-tertiary);
  font-size: 12px;
  text-align: center;
  line-height: 1.5;
}

/* ---- 分页 ---- */
.logs-pagination {
  flex-shrink: 0;
  padding: 0;
  border-top: none;
  background: transparent;
}

.logs-pagination .btn {
  min-width: 72px;
}

.logs-page-info {
  font-size: 12.5px;
  color: var(--text-secondary);
  line-height: 32px;
}

/* ============================================
   详情面板（桌面端）
   ============================================ */
.logs-detail-panel {
  flex: 1;
  display: flex;
  flex-direction: column;
  background: linear-gradient(168deg, #fafbff 0%, #f4f6fc 40%, #f0f2fa 100%);
  overflow: auto;
  position: relative;
}

.logs-detail-panel::before {
  content: '';
  position: absolute;
  top: 0;
  right: 0;
  width: 320px;
  height: 320px;
  background: radial-gradient(circle, rgba(67, 97, 238, 0.05) 0%, transparent 70%);
  pointer-events: none;
}

/* 移动端 Sheet 手柄（桌面端隐藏） */
.logs-sheet-handle {
  display: none;
}

/* ---- 详情占位符 ---- */
.logs-detail-placeholder {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 100%;
  text-align: center;
  padding: 40px;
  animation: fadeIn 0.4s ease;
  position: relative;
  z-index: 1;
}

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

.logs-detail-placeholder-icon {
  width: 80px;
  height: 80px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--primary-light) 0%, #e8ecff 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 20px;
  box-shadow: 0 4px 20px rgba(67, 97, 238, 0.08);
}

.logs-detail-placeholder-icon svg {
  width: 36px;
  height: 36px;
  color: var(--primary);
  opacity: 0.7;
}

.logs-detail-placeholder h3 {
  font-size: 16px;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 6px;
}

.logs-detail-placeholder p {
  font-size: 13px;
  color: var(--text-tertiary);
}

/* ---- 详情内容 ---- */
.logs-detail-content {
  padding: 32px;
  position: relative;
  z-index: 1;
  animation: slideInRight 0.3s ease;
}

@keyframes slideInRight {
  from { opacity: 0; transform: translateX(12px); }
  to { opacity: 1; transform: translateX(0); }
}

.logs-detail-header {
  margin-bottom: 28px;
}

.logs-detail-status-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 14px;
  flex-wrap: wrap;
}

.logs-detail-subject {
  font-size: 22px;
  font-weight: 700;
  color: var(--text);
  letter-spacing: -0.02em;
  line-height: 1.3;
  text-wrap: balance;
}

.logs-detail-body {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

/* ---- 详情分区卡片 ---- */
.logs-detail-section {
  background: var(--bg-white);
  border-radius: var(--radius-md);
  padding: 18px 20px;
  border: 1px solid var(--border-light);
  box-shadow: var(--shadow-xs);
}

.logs-detail-field {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 8px 0;
}

.logs-detail-field + .logs-detail-field {
  border-top: 1px solid var(--border-light);
}

.logs-detail-label {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 11.5px;
  font-weight: 700;
  color: var(--text-tertiary);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  white-space: nowrap;
  min-width: 76px;
  padding-top: 1px;
}

.logs-detail-label svg {
  width: 14px;
  height: 14px;
  opacity: 0.55;
}

.logs-detail-value {
  font-size: 14px;
  color: var(--text);
  line-height: 1.5;
  word-break: break-all;
  flex: 1;
}

.logs-detail-value.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
}

.logs-recipient-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 12.5px;
  font-weight: 500;
  padding: 4px 10px;
  border-radius: 12px;
  background: var(--primary-light);
  color: var(--primary);
  cursor: default;
  transition: background var(--transition-fast);
}

.logs-recipient-chip:hover {
  background: #dde1ff;
}

/* ---- 错误信息 ---- */
.logs-detail-error {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 12px 16px;
  background: var(--danger-light);
  border-radius: var(--radius-sm);
  font-size: 13px;
  color: var(--danger);
  line-height: 1.5;
  border: 1px solid #fecaca;
}

/* ---- 分区标题 ---- */
.logs-detail-section-title {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 11.5px;
  font-weight: 700;
  color: var(--text-tertiary);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-bottom: 14px;
}

.logs-detail-section-title svg {
  width: 14px;
  height: 14px;
  opacity: 0.55;
}

/* ---- 附件区 ---- */
.logs-detail-attachments {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.logs-detail-attachments .attachment-tag {
  font-size: 12px;
  padding: 4px 10px;
  border-radius: 12px;
  background: var(--bg-subtle);
  border: 1px solid var(--border-light);
}

.logs-detail-attachments .attachment-tag svg {
  width: 12px;
  height: 12px;
}

/* ---- 阅读追踪 ---- */
.logs-tracking-summary {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 14px;
}

.logs-tracking-refresh-btn {
  margin-left: auto;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  padding: 0;
  border: none;
  border-radius: 6px;
  background: transparent;
  color: var(--text-tertiary);
  cursor: pointer;
  text-transform: none;
  letter-spacing: normal;
  transition: background 0.15s, color 0.15s;
}

.logs-tracking-refresh-btn:hover {
  background: var(--bg-subtle);
  color: var(--text);
}

.logs-tracking-refresh-btn:active {
  transform: scale(0.92);
}

.logs-tracking-refresh-btn svg {
  width: 13px;
  height: 13px;
}

.logs-tracking-refresh-btn.refreshing svg {
  animation: logs-tracking-spin 0.8s linear infinite;
}

@keyframes logs-tracking-spin {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}

.logs-tracking-stat {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 12px;
  font-weight: 600;
  padding: 4px 10px;
  border-radius: 12px;
  background: var(--bg-subtle);
  color: var(--text-secondary);
}

.logs-tracking-stat.read-stat {
  background: #dbeafe;
  color: #2563eb;
}

.logs-tracking-stat.unread-stat {
  background: #fef3c7;
  color: #d97706;
}

.logs-tracking-stat.untrackable-stat {
  background: var(--gray-100);
  color: var(--gray-500);
}

.logs-tracking-list {
  display: flex;
  flex-direction: column;
  gap: 0;
}

.logs-tracking-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 0;
  gap: 12px;
}

.logs-tracking-item + .logs-tracking-item {
  border-top: 1px solid var(--border-light);
}

.logs-tracking-item-info {
  flex: 1;
  min-width: 0;
}

.logs-tracking-item-name {
  font-size: 13.5px;
  font-weight: 500;
  color: var(--text);
}

.logs-tracking-item-detail {
  font-size: 12px;
  color: var(--text-tertiary);
  margin-top: 2px;
}

/* ---- 邮件正文 ---- */
.logs-detail-body-content {
  font-size: 14px;
  line-height: 1.7;
  color: var(--text);
  word-break: break-word;
}

.logs-detail-body-content.logs-body-html {
  max-height: none;
}

.logs-detail-body-content.logs-body-text {
  white-space: pre-wrap;
  font-family: inherit;
}

.logs-detail-body-content img {
  max-width: 100%;
  height: auto;
}

.logs-detail-body-content a {
  color: var(--primary);
}

.logs-detail-body-content table {
  max-width: 100%;
}

.logs-body-iframe {
  display: block;
}

/* ---- 操作按钮 ---- */
.logs-detail-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding-top: 4px;
}

.logs-detail-actions .btn {
  font-size: 13px;
}

/* ============================================
   移动端底部 Sheet
   ============================================ */
.logs-sheet-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.5);
  backdrop-filter: blur(2px);
  z-index: 900;
  opacity: 0;
  visibility: hidden;
  transition: opacity var(--transition-base), visibility var(--transition-base);
}

.logs-sheet-overlay.active {
  opacity: 1;
  visibility: visible;
}

/* ============================================
   模态框增强（logs 专属）
   ============================================ */
.logs-modal {
  padding: 24px;
}

.logs-modal-title-group {
  display: flex;
  align-items: center;
  gap: 12px;
}

.logs-modal-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border-radius: 10px;
  background: var(--primary-light);
  color: var(--primary);
  flex-shrink: 0;
}

.logs-modal-icon svg {
  width: 18px;
  height: 18px;
}

.logs-modal-icon.danger {
  background: var(--danger-light);
  color: var(--danger);
}

.logs-modal-message {
  font-size: 15px;
  color: var(--text);
  font-weight: 500;
  line-height: 1.5;
}

.logs-modal-submessage {
  font-size: 13px;
  color: var(--text-tertiary);
  margin-top: 6px;
}

.logs-modal-server-tip {
  font-size: 12px;
  color: var(--text-tertiary);
  margin-top: 8px;
  padding: 8px 10px;
  background: var(--bg-secondary, #f5f5f7);
  border-radius: 6px;
  border-left: 2px solid var(--accent, #6366f1);
  line-height: 1.5;
}

.logs-modal-server-tip.hidden {
  display: none;
}

/* ============================================
   TEMPLATES PAGE - 邮件模板（独有样式）
   ============================================ */

/* Template list with padding */
.split-layout.templates .split-list {
  padding: 12px 16px;
}

/* Template item row */
.tpl-item {
  display: flex;
  align-items: center;
  padding: 14px 16px;
  border-radius: var(--radius-md);
  margin-bottom: 4px;
  transition: all var(--transition-fast);
  background: transparent;
  gap: 12px;
  cursor: pointer;
  border: 1px solid transparent;
}

.tpl-item:hover {
  background: var(--primary-subtle);
}

.tpl-item.active {
  background: var(--primary-light);
  border-color: var(--primary);
}

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

.tpl-info .tpl-name {
  font-size: 13.5px;
  font-weight: 600;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.tpl-info .tpl-subject {
  font-size: 12px;
  color: var(--text-tertiary);
  margin-top: 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Variable tags */
.tpl-vars {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-top: 6px;
}

.tpl-var-tag {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  padding: 2px 8px;
  border-radius: 10px;
  font-size: 11px;
  font-weight: 500;
  background: var(--primary-light);
  color: var(--primary);
  font-family: var(--font-mono);
}

.tpl-var-tag svg {
  width: 10px;
  height: 10px;
}

.tpl-var-tag.custom {
  background: var(--gray-100);
  color: var(--text-secondary);
}

/* Template actions - hidden in split layout */
.tpl-actions {
  display: none;
}

/* Preview content */
.tpl-preview-content {
  display: flex;
  flex-direction: column;
  height: 100%;
}

.tpl-preview-header {
  padding: 20px 24px;
  flex-shrink: 0;
  border-bottom: 1px solid var(--border-light);
  background: rgba(255, 255, 255, 0.6);
  backdrop-filter: blur(8px);
}

.tpl-preview-title-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.tpl-preview-name {
  font-size: 20px;
  font-weight: 700;
  color: var(--text);
  letter-spacing: -0.02em;
  line-height: 1.3;
}

.tpl-preview-actions {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}

.tpl-preview-meta {
  font-size: 13px;
  color: var(--text-tertiary);
  margin-top: 6px;
}

.tpl-preview-vars {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-top: 8px;
}

.tpl-preview-frame-wrapper {
  flex: 1;
  padding: 16px;
  overflow: hidden;
}

.tpl-preview-frame-wrapper iframe {
  width: 100%;
  height: 100%;
  border: 1px solid var(--border-light);
  border-radius: var(--radius-md);
  background: #fff;
}

/* ============================================
   TEMPLATE EDITOR - 模板编辑器
   ============================================ */
.template-editor-tabs {
  display: flex;
  gap: 0;
  margin-bottom: 0;
  border-bottom: 2px solid var(--border);
}

.template-tab {
  padding: 8px 20px;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--text-tertiary);
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
  cursor: pointer;
  transition: all var(--transition-fast);
  font-family: var(--font-sans);
}

.template-tab:hover {
  color: var(--primary);
}

.template-tab.active {
  color: var(--primary);
  border-bottom-color: var(--primary);
}

.template-editor-pane {
  margin-top: 0;
}

.template-source-editor {
  min-height: 300px;
  font-family: var(--font-mono);
  font-size: 13px;
  line-height: 1.6;
  resize: vertical;
  border-top-left-radius: 0;
  border-top-right-radius: 0;
}

/* ============================================
   TEMPLATE QUILL - 模板富文本编辑器
   ============================================ */
#templateQuill {
  height: 300px;
  font-size: 14px;
}

/* ============================================
   RESPONSIVE
   ============================================ */
@media (max-width: 900px) {
  .split-layout {
    flex-direction: column;
    height: auto;
  }

  .split-list-panel {
    flex: none;
    border-right: none;
    border-bottom: 1px solid var(--border-light);
    max-height: 50vh;
  }

  .split-detail-panel {
    min-height: 300px;
  }
}

@media (max-width: 768px) {
  .split-toolbar {
    padding: 14px 16px;
  }

  .email-log-item {
    padding: 12px 16px;
  }

  .email-log-meta,
  .email-log-attachments {
    padding-left: 0;
  }

  .split-menu-dropdown {
    right: -8px;
  }

  .logs-detail-content {
    padding: 20px;
  }

  .logs-detail-subject {
    font-size: 18px;
  }

  .split-layout.templates .split-list {
    padding: 10px 12px;
  }

  .tpl-item {
    padding: 12px 14px;
  }

  .tpl-preview-header {
    padding: 16px;
  }

  .tpl-preview-name {
    font-size: 17px;
  }

  .tpl-preview-frame-wrapper {
    padding: 10px;
  }
}

/* ============================================
   LOGS PAGE - 移动端响应式 + 底部 Sheet
   ============================================ */
@media (max-width: 900px) {
  /* 主布局：单列，只显示列表，去除大卡片容器视觉 */
  .logs-layout {
    flex-direction: column;
    height: calc(100vh - 96px);
    background: transparent;
    border-radius: 0;
    box-shadow: none;
    border: none;
    overflow: visible;
  }

  .logs-list-panel {
    flex: 1;
    border-right: none;
    max-height: none;
    background: transparent;
    /* 移动端列表面板需有明确高度约束，让内部列表可滚动触发无限加载 */
    min-height: 0;
    overflow: hidden;
  }

  /* 移动端列表恢复撑满剩余空间，确保可滚动溢出以触发 scroll 事件 */
  .logs-list-panel .logs-list {
    flex: 1 1 0;
    min-height: 0;
  }

  /* 详情面板：转为底部 Sheet */
  .logs-detail-panel {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    top: auto;
    height: 85vh;
    max-height: 85vh;
    z-index: 1000;
    background: var(--bg-white);
    border-radius: 16px 16px 0 0;
    box-shadow: 0 -8px 32px rgba(15, 23, 42, 0.18);
    transform: translateY(100%);
    transition: transform 320ms cubic-bezier(0.32, 0.72, 0, 1);
    overflow: hidden;
    display: flex;
    flex-direction: column;
  }

  .logs-detail-panel.active {
    transform: translateY(0);
  }

  /* 隐藏桌面端的渐变背景装饰 */
  .logs-detail-panel::before {
    display: none;
  }

  /* 显示拖拽手柄 */
  .logs-sheet-handle {
    display: block;
    flex-shrink: 0;
    width: 100%;
    padding: 10px 0 6px;
    cursor: grab;
    background: var(--bg-white);
    border-bottom: 1px solid var(--border-light);
    border-radius: 16px 16px 0 0;
  }

  .logs-sheet-handle::before {
    content: '';
    display: block;
    width: 36px;
    height: 4px;
    margin: 0 auto;
    border-radius: 2px;
    background: var(--gray-300);
    transition: background var(--transition-fast);
  }

  .logs-sheet-handle:active::before {
    background: var(--gray-400);
  }

  /* 详情内容区可滚动 */
  .logs-detail-content,
  .logs-detail-placeholder {
    flex: 1;
    overflow-y: auto;
    height: auto;
    min-height: 0;
  }

  .logs-detail-content {
    padding: 20px 16px 32px;
  }

  .logs-detail-placeholder {
    padding: 60px 24px;
  }

  .logs-detail-subject {
    font-size: 19px;
  }

  /* 遮罩层显示 */
  .logs-sheet-overlay {
    display: block;
  }
}

@media (max-width: 768px) {
  /* 工具栏紧凑化 */
  .logs-toolbar-head {
    padding: 12px 14px 10px;
  }

  .logs-toolbar-title {
    font-size: 16px;
  }

  .logs-action-btn {
    height: 32px;
    padding: 0 10px;
    font-size: 12px;
  }

  .logs-action-btn.icon-only {
    width: 32px;
  }

  /* 隐藏"同步"和"批量删除"文字，只保留图标 */
  .logs-action-btn:not(.icon-only) span {
    display: none;
  }

  .logs-action-btn:not(.icon-only) {
    width: 32px;
    padding: 0;
  }

  /* 筛选栏紧凑化 */
  .logs-filter-bar {
    padding: 8px 14px 12px;
  }

  .logs-filter-tab {
    padding: 5px 12px;
    font-size: 12px;
  }

  /* 列表容器 */
  .logs-list {
    padding: 10px 12px;
    gap: 8px;
  }

  /* 列表项紧凑化 */
  .email-log-item {
    padding: 12px 14px;
  }

  .email-log-subject {
    font-size: 13.5px;
  }

  .email-log-meta {
    padding-left: 0;
    font-size: 12px;
  }

  .email-log-attachments {
    padding-left: 0;
  }

  /* 详情分区紧凑化 */
  .logs-detail-section {
    padding: 14px 16px;
  }

  .logs-detail-header {
    margin-bottom: 20px;
  }

  .logs-detail-body {
    gap: 12px;
  }

  /* 模态框紧凑化 */
  .logs-modal {
    padding: 20px;
  }

  .logs-modal-icon {
    width: 32px;
    height: 32px;
  }

  .logs-modal-icon svg {
    width: 16px;
    height: 16px;
  }
}

@media (max-width: 480px) {
  /* 超小屏幕：详情面板几乎全屏 */
  .logs-detail-panel {
    height: 92vh;
    max-height: 92vh;
    border-radius: 12px 12px 0 0;
  }

  .logs-detail-content {
    padding: 16px 14px 28px;
  }

  .logs-detail-subject {
    font-size: 18px;
  }

  .logs-detail-section {
    padding: 12px 14px;
  }
}

/* ============================================
   动效偏好
   ============================================ */
@media (prefers-reduced-motion: reduce) {
  .logs-detail-panel {
    transition: none;
  }

  .logs-detail-content {
    animation: none;
  }

  .logs-detail-placeholder {
    animation: none;
  }

  .email-log-item {
    transition: none;
  }

  .logs-sheet-overlay {
    transition: none;
  }
}
