/* ===================================
   ChatGPT 凭证管理系统 - 玻璃磨砂风格
   =================================== */

/* --- CSS 变量 --- */
:root {
  --bg-base: #e8edf5;
  --bg-gradient-1: #dce4f2;
  --bg-gradient-2: #e2eaf8;

  --glass-bg: rgba(255, 255, 255, 0.55);
  --glass-bg-hover: rgba(255, 255, 255, 0.72);
  --glass-border: rgba(255, 255, 255, 0.65);
  --glass-border-hover: rgba(255, 255, 255, 0.85);
  --glass-shadow: rgba(100, 120, 180, 0.08);

  --accent: #2563eb;
  --accent-light: #3b82f6;
  --accent-lighter: #93c5fd;
  --accent-bg: rgba(37, 99, 235, 0.08);
  --accent-glow: rgba(37, 99, 235, 0.2);

  --accent-2: #0ea5e9;
  --accent-2-glow: rgba(14, 165, 233, 0.15);

  --text-primary: #1e293b;
  --text-secondary: #475569;
  --text-muted: #94a3b8;

  --imap-color: #e11d48;
  --imap-bg: rgba(225, 29, 72, 0.08);
  --graph-color: #059669;
  --graph-bg: rgba(5, 150, 105, 0.08);

  --success: #10b981;
  --success-bg: rgba(16, 185, 129, 0.08);
  --warning: #f59e0b;
  --warning-bg: rgba(245, 158, 11, 0.08);
  --error: #ef4444;
  --error-bg: rgba(239, 68, 68, 0.08);

  --radius-sm: 10px;
  --radius-md: 14px;
  --radius-lg: 18px;

  --shadow-sm: 0 1px 3px rgba(0,0,0,0.04), 0 1px 2px rgba(0,0,0,0.02);
  --shadow-md: 0 4px 16px rgba(100, 120, 180, 0.1), 0 1px 4px rgba(0,0,0,0.04);
  --shadow-lg: 0 8px 32px rgba(100, 120, 180, 0.15), 0 2px 8px rgba(0,0,0,0.05);

  --transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
  --transition-fast: all 0.15s cubic-bezier(0.4, 0, 0.2, 1);
}

/* --- 重置 --- */
*, *::before, *::after { margin: 0; padding: 0; box-sizing: border-box; }

html { font-size: 14px; -webkit-font-smoothing: antialiased; }

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'SF Pro Display', sans-serif;
  background: var(--bg-base);
  color: var(--text-primary);
  min-height: 100vh;
  overflow-x: hidden;
  line-height: 1.6;
}

/* --- 动态背景 --- */
.bg-animation {
  position: fixed; top: 0; left: 0;
  width: 100%; height: 100%;
  z-index: 0; overflow: hidden; pointer-events: none;
  background: linear-gradient(135deg, #e0e7ff 0%, #dbeafe 25%, #e0f2fe 50%, #ede9fe 75%, #e8edf5 100%);
}

.bg-orb {
  position: absolute; border-radius: 50%;
  filter: blur(100px); opacity: 0.6;
  animation: orbFloat 25s ease-in-out infinite;
}

.bg-orb-1 {
  width: 600px; height: 600px;
  background: radial-gradient(circle, rgba(147, 197, 253, 0.5), transparent 70%);
  top: -15%; left: -10%;
}

.bg-orb-2 {
  width: 500px; height: 500px;
  background: radial-gradient(circle, rgba(196, 181, 253, 0.4), transparent 70%);
  top: 40%; right: -10%;
  animation-delay: -8s;
}

.bg-orb-3 {
  width: 450px; height: 450px;
  background: radial-gradient(circle, rgba(165, 218, 255, 0.45), transparent 70%);
  bottom: -10%; left: 25%;
  animation-delay: -16s;
}

@keyframes orbFloat {
  0%, 100% { transform: translate(0, 0) scale(1); }
  25% { transform: translate(40px, -30px) scale(1.05); }
  50% { transform: translate(-25px, 25px) scale(0.95); }
  75% { transform: translate(20px, 40px) scale(1.03); }
}

/* --- 玻璃面板 --- */
.glass-panel {
  background: var(--glass-bg);
  backdrop-filter: blur(28px) saturate(1.4);
  -webkit-backdrop-filter: blur(28px) saturate(1.4);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md);
}

/* --- 容器 --- */
.app-container {
  position: relative; z-index: 1;
  max-width: 1680px; margin: 0 auto;
  padding: 20px; min-height: 100vh;
  display: flex; flex-direction: column; gap: 14px;
}

/* --- 顶部栏 --- */
.app-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 22px;
  background: rgba(255, 255, 255, 0.6);
  backdrop-filter: blur(28px) saturate(1.4);
  border: 1px solid rgba(255, 255, 255, 0.7);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
}

.header-left { display: flex; align-items: center; gap: 12px; }

.app-icon {
  width: 42px; height: 42px; border-radius: 12px;
  background: linear-gradient(135deg, #3b82f6, #06b6d4);
  display: flex; align-items: center; justify-content: center;
  color: white;
  box-shadow: 0 4px 12px rgba(59, 130, 246, 0.3);
}

.app-title { font-size: 1.25rem; font-weight: 700; color: var(--text-primary); }
.app-subtitle { font-size: 0.75rem; color: var(--text-muted); font-weight: 400; margin-top: 1px; }

.header-right { display: flex; align-items: center; gap: 10px; }

.status-badge {
  display: flex; align-items: center; gap: 6px;
  padding: 6px 14px; border-radius: 20px;
  background: var(--success-bg);
  border: 1px solid rgba(16, 185, 129, 0.15);
  font-size: 0.78rem; color: var(--success); font-weight: 500;
}

.status-badge.loading { background: var(--warning-bg); border-color: rgba(245, 158, 11, 0.15); color: var(--warning); }
.status-badge.error { background: var(--error-bg); border-color: rgba(239, 68, 68, 0.15); color: var(--error); }

.status-dot {
  width: 7px; height: 7px; border-radius: 50%;
  background: currentColor;
  animation: pulse 2s ease-in-out infinite;
}

@keyframes pulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.4; transform: scale(0.8); }
}

/* --- Tab 导航 --- */
.tab-nav {
  display: flex; gap: 4px; padding: 6px;
  overflow-x: auto;
}

.tab-btn {
  display: flex; align-items: center; gap: 6px;
  padding: 10px 20px; border: none;
  border-radius: 12px; background: transparent;
  color: var(--text-muted); font-family: inherit;
  font-size: 0.88rem; font-weight: 500;
  cursor: pointer; transition: var(--transition);
  white-space: nowrap;
}

.tab-btn:hover { background: rgba(255, 255, 255, 0.5); color: var(--text-secondary); }

.tab-btn.active {
  background: linear-gradient(135deg, #3b82f6, #2563eb);
  color: white;
  box-shadow: 0 2px 12px rgba(37, 99, 235, 0.25);
}

.tab-content { display: none; flex: 1; min-height: 0; }
.tab-content.active { display: flex; flex-direction: column; gap: 12px; animation: fadeInUp 0.3s ease; }

/* --- Tab 1: 邮箱管理布局 --- */
.main-layout { display: flex; gap: 14px; flex: 1; min-height: 0; }

.sidebar {
  width: 360px; min-width: 360px;
  display: flex; flex-direction: column;
  padding: 16px; gap: 12px;
  max-height: calc(100vh - 180px);
}

.panel-header { display: flex; align-items: center; justify-content: space-between; }

.panel-title {
  font-size: 0.88rem; font-weight: 600;
  display: flex; align-items: center; gap: 8px;
  color: var(--text-secondary);
}

.panel-title svg { opacity: 0.5; }

.content { flex: 1; display: flex; flex-direction: column; gap: 12px; min-width: 0; }

/* --- 搜索区 --- */
.account-search { position: relative; display: flex; align-items: center; }
.account-search-icon { position: absolute; left: 12px; color: var(--text-muted); pointer-events: none; }
.account-search-input {
  width: 100%; padding: 9px 12px 9px 36px;
  border-radius: 8px; border: 1px solid rgba(0, 0, 0, 0.06);
  background: rgba(255, 255, 255, 0.68); color: var(--text-primary);
  font-family: inherit; font-size: 0.82rem;
  outline: none; transition: var(--transition-fast);
}
.account-search-input:focus {
  border-color: var(--accent-light);
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
  background: rgba(255, 255, 255, 0.9);
}
.account-search-input::placeholder { color: var(--text-muted); }

/* --- Badge --- */
.badge {
  background: var(--accent-bg); color: var(--accent);
  padding: 2px 10px; border-radius: 20px;
  font-size: 0.72rem; font-weight: 600;
}
.badge-pulse { animation: badgePulse 0.6s ease; }
@keyframes badgePulse { 0% { transform: scale(1); } 50% { transform: scale(1.2); } 100% { transform: scale(1); } }
.badge-imap { background: var(--imap-bg); color: var(--imap-color); }
.badge-graph { background: var(--graph-bg); color: var(--graph-color); }

/* --- 按钮系统 --- */
.btn {
  display: inline-flex; align-items: center; justify-content: center;
  gap: 6px; padding: 9px 18px;
  border-radius: var(--radius-sm); border: none;
  font-family: inherit; font-size: 0.82rem; font-weight: 500;
  cursor: pointer; transition: var(--transition);
  white-space: nowrap; outline: none;
}
.btn:active { transform: scale(0.97); }

.btn-primary {
  background: linear-gradient(135deg, #3b82f6, #2563eb);
  color: white;
  box-shadow: 0 2px 10px rgba(37, 99, 235, 0.25);
}
.btn-primary:hover { box-shadow: 0 4px 18px rgba(37, 99, 235, 0.35); transform: translateY(-1px); }

.btn-accent {
  background: linear-gradient(135deg, #0ea5e9, #0284c7);
  color: white;
  box-shadow: 0 2px 10px rgba(14, 165, 233, 0.25);
}
.btn-accent:hover { box-shadow: 0 4px 18px rgba(14, 165, 233, 0.35); transform: translateY(-1px); }

.btn-success {
  background: linear-gradient(135deg, #10b981, #059669);
  color: white;
  box-shadow: 0 2px 10px rgba(16, 185, 129, 0.25);
}

.btn-danger {
  background: linear-gradient(135deg, #ef4444, #dc2626);
  color: white;
  box-shadow: 0 2px 10px rgba(239, 68, 68, 0.25);
}

.btn-ghost {
  background: rgba(255, 255, 255, 0.5);
  color: var(--text-secondary);
  border: 1px solid rgba(0, 0, 0, 0.06);
}
.btn-ghost:hover { background: rgba(255, 255, 255, 0.8); color: var(--text-primary); }

.btn-full { width: 100%; }
.btn-small { padding: 6px 12px; font-size: 0.75rem; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; transform: none !important; }
.btn-danger-ghost {
  color: var(--error); border-color: rgba(239, 68, 68, 0.2);
  background: rgba(239, 68, 68, 0.04);
}
.btn-danger-ghost:hover { background: var(--error-bg); }

/* --- 邮箱列表 --- */
.import-section { display: flex; flex-direction: column; gap: 8px; }

.account-list {
  flex: 1; overflow-y: auto;
  display: flex; flex-direction: column;
  gap: 5px; padding-right: 4px;
}
.account-list::-webkit-scrollbar { width: 4px; }
.account-list::-webkit-scrollbar-track { background: transparent; }
.account-list::-webkit-scrollbar-thumb { background: rgba(0, 0, 0, 0.08); border-radius: 4px; }

.select-all-wrapper {
  display: flex; align-items: center; gap: 8px;
  padding: 6px 10px; font-size: 0.78rem;
  color: var(--text-muted); font-weight: 500;
}

.account-item {
  display: flex; align-items: center; gap: 8px;
  padding: 10px 12px; border-radius: 8px;
  background: rgba(255, 255, 255, 0.35);
  border: 1px solid transparent;
  cursor: pointer; transition: var(--transition-fast);
  animation: fadeInUp 0.3s ease both;
}
.account-item:hover { background: rgba(255, 255, 255, 0.6); border-color: rgba(0, 0, 0, 0.04); }
.account-item.selected { background: rgba(37, 99, 235, 0.06); border-color: rgba(37, 99, 235, 0.15); }
.account-item-new { animation: slideInHighlight 0.4s ease both; }
.account-item-removing { animation: fadeOutRemove 0.3s ease forwards; }

@keyframes slideInHighlight {
  0% { opacity: 0; transform: translateX(-20px); background: rgba(37, 99, 235, 0.15); }
  100% { opacity: 1; transform: translateX(0); background: rgba(255, 255, 255, 0.35); }
}
@keyframes fadeOutRemove {
  0% { opacity: 1; transform: scale(1); }
  100% { opacity: 0; transform: scale(0.95); height: 0; padding: 0; margin: 0; overflow: hidden; }
}

.account-checkbox {
  appearance: none; width: 16px; height: 16px;
  border: 1.5px solid var(--text-muted); border-radius: 5px;
  cursor: pointer; transition: var(--transition-fast);
  flex-shrink: 0; position: relative; background: white;
}
.account-checkbox:checked { background: var(--accent); border-color: var(--accent); }
.account-checkbox:checked::after {
  content: ''; position: absolute; top: 2px; left: 5px;
  width: 4px; height: 8px;
  border: solid white; border-width: 0 1.5px 1.5px 0;
  transform: rotate(45deg);
}

.account-email {
  font-size: 0.85rem; color: var(--text-primary); flex: 1;
  min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}

.account-copy, .account-delete { opacity: 0; transition: var(--transition-fast); flex-shrink: 0; }
.account-item:hover .account-copy, .account-item:hover .account-delete { opacity: 0.5; }
.account-copy:hover, .account-delete:hover { opacity: 1 !important; }

.account-copy {
  width: 24px; height: 24px;
  background: rgba(37, 99, 235, 0.06); border: 1px solid rgba(37, 99, 235, 0.08);
  color: var(--accent); cursor: pointer; border-radius: 7px;
  display: inline-flex; align-items: center; justify-content: center;
}
.account-delete {
  background: none; border: none; color: var(--error);
  cursor: pointer; padding: 2px; border-radius: 4px;
}
.account-delete:hover { background: var(--error-bg); }

.sidebar-footer { border-top: 1px solid rgba(0, 0, 0, 0.05); padding-top: 12px; }

/* --- 搜索控制区 --- */
.control-panel { padding: 16px 20px; display: flex; flex-direction: column; gap: 12px; }
.control-row { display: flex; align-items: center; gap: 10px; }
.control-actions { justify-content: space-between; }
.flex-grow { flex: 1; }

.input-group { position: relative; display: flex; align-items: center; }
.input-icon { position: absolute; left: 12px; color: var(--text-muted); pointer-events: none; z-index: 1; }

.input {
  width: 100%; padding: 9px 14px 9px 38px;
  border-radius: 8px; border: 1px solid rgba(0, 0, 0, 0.06);
  background: rgba(255, 255, 255, 0.7); color: var(--text-primary);
  font-family: inherit; font-size: 0.82rem;
  outline: none; transition: var(--transition-fast);
}
.input:focus { border-color: var(--accent-light); box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.12); background: rgba(255, 255, 255, 0.9); }
.input::placeholder { color: var(--text-muted); }

.select {
  padding-left: 14px; appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%2394a3b8' stroke-width='2' xmlns='http://www.w3.org/2000/svg'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 10px center;
  padding-right: 30px; cursor: pointer;
}
.input-narrow { width: 110px; min-width: 110px; }

.protocol-toggles { display: flex; gap: 8px; }
.toggle-label { cursor: pointer; }
.toggle-label input { display: none; }
.toggle-pill {
  display: inline-block; padding: 5px 14px;
  border-radius: 20px; font-size: 0.75rem; font-weight: 600;
  border: 1px solid rgba(0, 0, 0, 0.06);
  color: var(--text-muted); background: rgba(255, 255, 255, 0.5);
  transition: var(--transition-fast);
}
.toggle-label input:checked + .toggle-pill {
  border-color: rgba(37, 99, 235, 0.25); color: var(--accent);
  background: rgba(37, 99, 235, 0.06);
}
.action-buttons { display: flex; gap: 8px; }

/* --- 进度条 --- */
.progress-bar-container {
  background: rgba(255, 255, 255, 0.6);
  backdrop-filter: blur(20px);
  border: 1px solid rgba(255, 255, 255, 0.7);
  border-radius: var(--radius-md);
  padding: 14px 18px; box-shadow: var(--shadow-sm);
  animation: fadeInUp 0.3s ease;
}
.progress-info { display: flex; justify-content: space-between; font-size: 0.78rem; margin-bottom: 10px; color: var(--text-secondary); font-weight: 500; }
.progress-track { width: 100%; height: 6px; background: rgba(0, 0, 0, 0.04); border-radius: 6px; overflow: hidden; }
.progress-fill {
  height: 100%; width: 0%;
  background: linear-gradient(90deg, #3b82f6, #06b6d4);
  border-radius: 6px; transition: width 0.4s ease; position: relative;
}
.progress-fill::after {
  content: ''; position: absolute; top: 0; left: 0;
  width: 100%; height: 100%;
  background: linear-gradient(90deg, transparent, rgba(255,255,255,0.4), transparent);
  animation: shimmer 1.5s infinite;
}

@keyframes shimmer { 0% { transform: translateX(-100%); } 100% { transform: translateX(100%); } }

/* --- 邮件结果 --- */
.results-section { flex: 1; display: flex; flex-direction: column; min-height: 0; }
.results-header { display: none; align-items: center; justify-content: space-between; padding: 8px 4px; }
.results-header.visible { display: flex; }
.results-title {
  font-size: 0.88rem; font-weight: 600;
  display: flex; align-items: center; gap: 8px;
  color: var(--text-secondary);
}
.results-meta { display: flex; gap: 8px; }

.email-list { flex: 1; overflow-y: auto; display: flex; flex-direction: column; gap: 8px; padding: 4px 0; }
.email-list::-webkit-scrollbar { width: 4px; }
.email-list::-webkit-scrollbar-thumb { background: rgba(0, 0, 0, 0.08); border-radius: 4px; }

.email-card {
  padding: 14px 18px; border-radius: var(--radius-md);
  background: rgba(255, 255, 255, 0.5);
  border: 1px solid rgba(255, 255, 255, 0.6);
  cursor: pointer; transition: var(--transition-fast);
  animation: fadeInUp 0.3s ease both;
}
.email-card:hover { background: rgba(255, 255, 255, 0.75); border-color: rgba(0, 0, 0, 0.06); transform: translateY(-1px); box-shadow: var(--shadow-sm); }

.email-card-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 6px; }
.email-from { font-size: 0.82rem; font-weight: 600; color: var(--text-primary); display: flex; align-items: center; gap: 8px; }
.email-date { font-size: 0.72rem; color: var(--text-muted); }
.email-subject { font-size: 0.88rem; font-weight: 500; color: var(--text-primary); margin-bottom: 4px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.email-preview { font-size: 0.78rem; color: var(--text-muted); line-height: 1.5; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.email-account-tag { font-size: 0.72rem; color: var(--text-muted); margin-top: 6px; }

.email-protocol {
  display: inline-block; padding: 1px 8px;
  border-radius: 10px; font-size: 0.65rem; font-weight: 700;
  text-transform: uppercase;
}
.email-protocol.imap { background: var(--imap-bg); color: var(--imap-color); }
.email-protocol.graph { background: var(--graph-bg); color: var(--graph-color); }

/* --- Tab 2: 登录管理 --- */
.login-section { display: flex; flex-direction: column; gap: 12px; flex: 1; }

.login-header {
  padding: 16px 22px;
}
.login-stats {
  display: flex; flex-wrap: wrap; gap: 14px;
  font-size: 0.82rem; font-weight: 600; color: var(--text-muted);
}
.login-stats span { white-space: nowrap; }
.login-stats .count-value { font-weight: 700; color: var(--text-primary); }

.login-toolbar {
  display: flex; flex-wrap: wrap; align-items: center; gap: 8px;
  padding: 12px 18px;
  border-top: 1px solid rgba(0, 0, 0, 0.04);
}

.concurrency-input {
  display: flex; align-items: center; gap: 6px;
  padding: 5px 12px; border-radius: 10px;
  border: 1px solid rgba(0, 0, 0, 0.06);
  background: rgba(255, 255, 255, 0.6);
  font-size: 0.78rem; color: var(--text-muted); font-weight: 600;
}
.concurrency-input input {
  width: 48px; border: 1px solid rgba(0, 0, 0, 0.06);
  border-radius: 6px; padding: 4px 6px; text-align: center;
  font-family: inherit; font-size: 0.82rem; font-weight: 700;
  color: var(--accent); background: white; outline: none;
}
.concurrency-input input:focus { border-color: var(--accent-light); }

.export-group { display: flex; align-items: center; gap: 6px; margin-left: auto; }
.export-select {
  padding: 6px 28px 6px 10px; border-radius: 8px;
  border: 1px solid rgba(0, 0, 0, 0.06); background: white;
  font-family: inherit; font-size: 0.78rem; font-weight: 600;
  color: var(--text-secondary); outline: none; appearance: none; cursor: pointer;
  background-image: url("data:image/svg+xml,%3Csvg width='10' height='10' viewBox='0 0 24 24' fill='none' stroke='%2394a3b8' stroke-width='2' xmlns='http://www.w3.org/2000/svg'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 8px center;
}

/* --- 登录表格 --- */
.login-table-wrapper {
  flex: 1; overflow: auto; border-radius: var(--radius-md);
  border: 1px solid rgba(0, 0, 0, 0.04);
}
.login-table-wrapper::-webkit-scrollbar { width: 4px; height: 4px; }
.login-table-wrapper::-webkit-scrollbar-thumb { background: rgba(0, 0, 0, 0.08); border-radius: 4px; }

.login-table {
  width: 100%; border-collapse: collapse; font-size: 0.82rem;
  min-width: 900px;
}
.login-table th, .login-table td {
  padding: 10px 14px; text-align: left; border-bottom: 1px solid rgba(0, 0, 0, 0.04);
  white-space: nowrap;
}
.login-table th {
  position: sticky; top: 0; z-index: 2;
  background: rgba(248, 250, 252, 0.95); backdrop-filter: blur(8px);
  color: var(--text-muted); font-size: 0.72rem; font-weight: 700;
  text-transform: uppercase; letter-spacing: 0.5px;
}
.login-table tr:hover td { background: rgba(37, 99, 235, 0.02); }
.login-table td.cell-email { max-width: 200px; overflow: hidden; text-overflow: ellipsis; }
.login-table td.cell-error { max-width: 180px; overflow: hidden; text-overflow: ellipsis; color: var(--error); font-size: 0.75rem; }
.login-table td.cell-error.error-account-deactivated {
  color: #b45309;
  font-weight: 700;
}

.status-cell {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 3px 10px; border-radius: 8px;
  font-size: 0.72rem; font-weight: 700;
}
.status-idle { background: rgba(148, 163, 184, 0.1); color: var(--text-muted); }
.status-logging { background: var(--warning-bg); color: var(--warning); }
.status-success { background: var(--success-bg); color: var(--success); }
.status-failed { background: var(--error-bg); color: var(--error); }

.spinner-small {
  width: 12px; height: 12px;
  border: 2px solid rgba(245, 158, 11, 0.2);
  border-top-color: var(--warning);
  border-radius: 50%; animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.login-progress {
  padding: 16px 20px; border-radius: var(--radius-lg);
  background: #0f172a; color: white;
}
.login-progress-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; }
.login-progress-header h3 { font-size: 0.88rem; font-weight: 600; }
.login-progress-stats { font-size: 0.82rem; color: rgba(255,255,255,0.7); }
.login-progress-stats .highlight { color: white; font-size: 1.1rem; font-weight: 700; }
.login-progress-stats .success-count { color: #34d399; }
.login-progress-bar { height: 8px; border-radius: 4px; background: rgba(255,255,255,0.1); overflow: hidden; }
.login-progress-fill {
  height: 100%; border-radius: 4px;
  background: linear-gradient(90deg, #6366f1, #34d399);
  transition: width 0.5s ease;
}

/* --- Tab 3/4: 转换器与提取器 --- */
.converter-section, .extractor-section { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; flex: 1; }
.converter-panel, .extractor-panel { display: flex; flex-direction: column; padding: 16px; gap: 12px; min-width: 0; }
.converter-panel h3, .extractor-panel h3 { font-size: 0.92rem; font-weight: 600; color: var(--text-secondary); display: flex; align-items: center; gap: 8px; }

.format-selector {
  display: inline-flex; padding: 3px;
  border: 1px solid rgba(0, 0, 0, 0.06);
  border-radius: 10px; background: rgba(255, 255, 255, 0.5);
}
.format-btn {
  padding: 7px 18px; border: none; border-radius: 8px;
  background: transparent; color: var(--text-muted);
  font-family: inherit; font-size: 0.78rem; font-weight: 700;
  cursor: pointer; transition: var(--transition-fast);
}
.format-btn.active {
  background: linear-gradient(135deg, #3b82f6, #2563eb);
  color: white; box-shadow: 0 2px 8px rgba(37, 99, 235, 0.2);
}

.converter-textarea {
  flex: 1; width: 100%; min-height: 300px;
  resize: vertical; border: 1px solid rgba(0, 0, 0, 0.06);
  border-radius: var(--radius-sm); padding: 12px;
  background: rgba(255, 255, 255, 0.6); color: var(--text-primary);
  font-family: 'SF Mono', 'Fira Code', 'Cascadia Code', Consolas, monospace;
  font-size: 0.78rem; line-height: 1.55;
  outline: none; transition: var(--transition-fast);
}
.converter-textarea:focus { border-color: var(--accent-light); box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1); }
.converter-textarea[readonly] { background: rgba(248, 250, 252, 0.7); }

.stats-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.stat-card {
  padding: 12px; border-radius: var(--radius-sm);
  border: 1px solid rgba(0, 0, 0, 0.04);
  background: rgba(255, 255, 255, 0.4);
}
.stat-value {
  font-family: 'SF Mono', Consolas, monospace;
  font-size: 1.2rem; font-weight: 800; color: var(--accent);
}
.stat-label { font-size: 0.72rem; color: var(--text-muted); margin-top: 2px; }

.converter-actions, .extractor-actions { display: flex; gap: 8px; flex-wrap: wrap; }

.file-drop-zone {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  min-height: 96px; padding: 18px; border: 1px dashed rgba(37, 99, 235, 0.32);
  border-radius: var(--radius-md); background: rgba(37, 99, 235, 0.04);
  color: var(--text-secondary); text-align: center; cursor: pointer;
  transition: var(--transition-fast);
}
.file-drop-zone:hover, .file-drop-zone.dragover {
  border-color: rgba(37, 99, 235, 0.68);
  background: rgba(37, 99, 235, 0.08);
}
.file-drop-title { font-weight: 700; font-size: 0.92rem; color: var(--text-primary); }
.file-drop-subtitle { margin-top: 6px; font-size: 0.76rem; color: var(--text-muted); line-height: 1.5; }

.extract-login-tools {
  display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap;
  padding: 10px 12px; border: 1px solid rgba(0, 0, 0, 0.05);
  border-radius: var(--radius-sm); background: rgba(255, 255, 255, 0.48);
}
.extract-format-group { display: flex; align-items: center; gap: 8px; font-size: 0.78rem; font-weight: 700; color: var(--text-muted); }
.extract-format-group .export-select { min-width: 112px; }
.extract-format-static {
  padding: 6px 10px; border-radius: 8px;
  border: 1px solid rgba(37, 99, 235, 0.16);
  background: rgba(37, 99, 235, 0.06);
  color: var(--accent); font-size: 0.78rem; font-weight: 800;
}

.extract-field-panel {
  padding: 10px 12px; border: 1px solid rgba(0, 0, 0, 0.05);
  border-radius: var(--radius-sm); background: rgba(255, 255, 255, 0.48);
}
.extract-field-title { font-size: 0.76rem; font-weight: 800; color: var(--text-muted); margin-bottom: 8px; }
.extract-field-list { display: flex; flex-wrap: wrap; gap: 8px; }
.extract-field-option {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 6px 10px; border: 1px solid rgba(0, 0, 0, 0.06);
  border-radius: 8px; background: rgba(255, 255, 255, 0.72);
  color: var(--text-secondary); font-size: 0.76rem; font-weight: 700;
  cursor: pointer; user-select: none;
}
.extract-field-option input { accent-color: var(--accent); }

.extractor-table-wrapper {
  min-height: 180px; max-height: 260px; overflow: auto;
  border: 1px solid rgba(0, 0, 0, 0.06); border-radius: var(--radius-sm);
  background: rgba(255, 255, 255, 0.42);
}
.extractor-table { width: 100%; min-width: 1120px; border-collapse: collapse; font-size: 0.78rem; }
.extractor-table th, .extractor-table td {
  padding: 9px 10px; text-align: left; border-bottom: 1px solid rgba(0, 0, 0, 0.05);
  vertical-align: top;
}
.extractor-table th {
  position: sticky; top: 0; z-index: 1;
  background: rgba(248, 250, 252, 0.95); color: var(--text-muted);
  font-size: 0.72rem; font-weight: 700;
}
.extractor-table td.cell-token {
  max-width: 520px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  font-family: 'SF Mono', Consolas, monospace; color: var(--text-secondary);
}
.extractor-table td.cell-email { max-width: 220px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.extractor-table td.cell-password {
  max-width: 180px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  font-family: 'SF Mono', Consolas, monospace; color: var(--text-secondary);
}
.extractor-table td.cell-client-id,
.extractor-table td.cell-refresh-token {
  max-width: 220px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  font-family: 'SF Mono', Consolas, monospace; color: var(--text-secondary);
}
.empty-state.compact { padding: 24px 12px; color: var(--text-muted); font-size: 0.82rem; text-align: center; }

/* --- Tab 5: 日志 --- */
.log-section {
  flex: 1; padding: 16px;
  background: #0f172a !important; border: 1px solid #1e293b !important;
  color: #e2e8f0; font-family: 'SF Mono', Consolas, monospace;
  font-size: 0.78rem; overflow-y: auto;
  max-height: calc(100vh - 200px);
}
.log-section::-webkit-scrollbar { width: 4px; }
.log-section::-webkit-scrollbar-thumb { background: rgba(255, 255, 255, 0.1); border-radius: 4px; }

.log-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; }
.log-header h3 { color: #94a3b8; font-size: 0.82rem; }
.log-list { display: flex; flex-direction: column; gap: 2px; }

.log-entry {
  padding: 5px 0;
  display: grid;
  grid-template-columns: 76px 52px minmax(0, 1fr);
  gap: 10px;
  line-height: 1.45;
  border-bottom: 1px solid rgba(148, 163, 184, 0.06);
}
.log-time { color: #475569; min-width: 80px; flex-shrink: 0; }
.log-type {
  display: inline-block; padding: 0 6px;
  border-radius: 4px; font-size: 0.68rem; font-weight: 700;
  min-width: 44px; text-align: center; flex-shrink: 0;
}
.log-type.info { background: rgba(59, 130, 246, 0.2); color: #93c5fd; }
.log-type.success { background: rgba(16, 185, 129, 0.2); color: #6ee7b7; }
.log-type.warning { background: rgba(245, 158, 11, 0.2); color: #fcd34d; }
.log-type.error { background: rgba(239, 68, 68, 0.2); color: #fca5a5; }
.log-message { color: #cbd5e1; word-break: break-all; }

/* --- 弹窗 --- */
.modal-overlay {
  position: fixed; top: 0; left: 0;
  width: 100%; height: 100%;
  background: rgba(15, 23, 42, 0.4);
  backdrop-filter: blur(4px);
  display: none; align-items: center; justify-content: center;
  z-index: 1000;
}
.modal-overlay.active { display: flex; }

.modal {
  width: 90%; max-width: 560px;
  padding: 0; animation: modalIn 0.25s ease;
}
.modal-large { max-width: 800px; max-height: 80vh; display: flex; flex-direction: column; }

@keyframes modalIn { 0% { opacity: 0; transform: scale(0.95) translateY(10px); } 100% { opacity: 1; transform: scale(1) translateY(0); } }

.modal-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 18px 22px; border-bottom: 1px solid rgba(0, 0, 0, 0.05);
}
.modal-header h3 { font-size: 1rem; font-weight: 600; }
.modal-body { padding: 18px 22px; overflow-y: auto; }
.modal-footer {
  display: flex; align-items: center; justify-content: flex-end; gap: 8px;
  padding: 14px 22px; border-top: 1px solid rgba(0, 0, 0, 0.05);
}

.btn-close {
  width: 32px; height: 32px; border: none;
  background: rgba(0, 0, 0, 0.04); border-radius: 8px;
  font-size: 1.2rem; cursor: pointer; color: var(--text-muted);
  display: flex; align-items: center; justify-content: center;
  transition: var(--transition-fast);
}
.btn-close:hover { background: rgba(0, 0, 0, 0.08); color: var(--text-primary); }

.modal-tip { font-size: 0.82rem; color: var(--text-secondary); margin-bottom: 10px; line-height: 1.5; }
.modal-tip code { background: rgba(37, 99, 235, 0.06); color: var(--accent); padding: 2px 6px; border-radius: 4px; font-size: 0.78rem; }

.textarea {
  width: 100%; border: 1px solid rgba(0, 0, 0, 0.06);
  border-radius: var(--radius-sm); padding: 12px;
  background: rgba(255, 255, 255, 0.7); color: var(--text-primary);
  font-family: 'SF Mono', Consolas, monospace; font-size: 0.8rem;
  outline: none; resize: vertical; transition: var(--transition-fast);
  line-height: 1.5;
}
.textarea:focus { border-color: var(--accent-light); box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1); }
.textarea-error { border-color: var(--error) !important; }

.import-preview {
  margin-top: 8px; padding: 8px 12px; border-radius: 8px;
  background: rgba(37, 99, 235, 0.04); font-size: 0.78rem;
  color: var(--text-secondary);
}
.preview-valid { color: var(--success); }
.preview-dup { color: var(--warning); }
.preview-error { color: var(--error); }
.preview-hint { color: var(--text-muted); }

/* --- Toast --- */
.toast-container {
  position: fixed; top: 20px; right: 20px;
  z-index: 2000; display: flex; flex-direction: column; gap: 8px;
}

.toast {
  display: flex; align-items: center; gap: 8px;
  padding: 12px 18px; border-radius: var(--radius-sm);
  background: rgba(255, 255, 255, 0.9);
  backdrop-filter: blur(20px);
  border: 1px solid rgba(255, 255, 255, 0.8);
  box-shadow: var(--shadow-lg);
  font-size: 0.82rem; font-weight: 500;
  animation: slideInRight 0.3s ease;
  cursor: pointer;
  max-width: 400px;
}

.toast.success { border-left: 3px solid var(--success); }
.toast.error { border-left: 3px solid var(--error); }
.toast.warning { border-left: 3px solid var(--warning); }
.toast.info { border-left: 3px solid var(--accent); }
.toast-exit { animation: slideOutRight 0.3s ease forwards; }

@keyframes slideInRight { 0% { opacity: 0; transform: translateX(40px); } 100% { opacity: 1; transform: translateX(0); } }
@keyframes slideOutRight { 0% { opacity: 1; transform: translateX(0); } 100% { opacity: 0; transform: translateX(40px); } }
@keyframes fadeInUp { 0% { opacity: 0; transform: translateY(8px); } 100% { opacity: 1; transform: translateY(0); } }

/* --- 空状态 --- */
.empty-state {
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  padding: 40px 20px; color: var(--text-muted); gap: 6px; text-align: center;
}
.empty-state svg { opacity: 0.15; margin-bottom: 6px; }
.empty-state p { font-size: 0.82rem; }
.text-muted { color: var(--text-muted); font-size: 0.75rem; }

/* --- 骨架屏 --- */
.skeleton {
  background: linear-gradient(90deg, rgba(0,0,0,0.04) 25%, rgba(0,0,0,0.08) 50%, rgba(0,0,0,0.04) 75%);
  background-size: 200% 100%;
  animation: skeletonShimmer 1.5s infinite;
  border-radius: var(--radius-md);
}
.skeleton-card { height: 100px; }
@keyframes skeletonShimmer { 0% { background-position: 200% 0; } 100% { background-position: -200% 0; } }

/* --- 按钮 spinner --- */
.btn-spinner {
  width: 14px; height: 14px;
  border: 2px solid rgba(255,255,255,0.3);
  border-top-color: white;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

/* --- 成功横幅 --- */
.import-success-banner {
  position: fixed; top: -80px; left: 50%;
  transform: translateX(-50%);
  display: flex; align-items: center; gap: 12px;
  padding: 16px 28px; border-radius: 16px;
  background: linear-gradient(135deg, #10b981, #059669);
  color: white; font-weight: 600;
  box-shadow: 0 8px 32px rgba(16, 185, 129, 0.35);
  transition: top 0.5s cubic-bezier(0.34, 1.56, 0.64, 1);
  z-index: 3000;
}
.import-success-banner.active { top: 24px; }
.import-success-banner.exit { top: -80px; }

/* --- 抖动动画 --- */
.shake { animation: shakeAnim 0.5s ease; }
@keyframes shakeAnim { 0%, 100% { transform: translateX(0); } 20%, 60% { transform: translateX(-6px); } 40%, 80% { transform: translateX(6px); } }

/* --- 高亮侧边栏 --- */
.sidebar-highlight { animation: sidebarPulse 1.5s ease; }
@keyframes sidebarPulse { 0%, 100% { box-shadow: var(--shadow-md); } 50% { box-shadow: 0 0 0 4px rgba(37, 99, 235, 0.2), var(--shadow-md); } }

/* --- 取件错误 --- */
.fetch-issues { margin: 2px 0 10px; padding: 12px 14px; border-radius: var(--radius-md); background: rgba(245, 158, 11, 0.08); border: 1px solid rgba(245, 158, 11, 0.18); }
.fetch-issues-title { display: flex; align-items: center; justify-content: space-between; font-size: 0.82rem; font-weight: 600; color: #92400e; margin-bottom: 8px; }

/* --- 响应式 --- */
@media (max-width: 1200px) {
  .main-layout { flex-direction: column; }
  .sidebar { width: 100%; min-width: auto; max-height: 300px; }
  .converter-section, .extractor-section { grid-template-columns: 1fr; }
}

@media (max-width: 768px) {
  .app-container { padding: 12px; }
  .app-header { padding: 10px 16px; flex-wrap: wrap; gap: 8px; }
  .tab-nav { padding: 4px; }
  .tab-btn { padding: 8px 14px; font-size: 0.8rem; }
  .control-row { flex-wrap: wrap; }
  .login-toolbar { flex-wrap: wrap; }
}
