/* =========================================================================
   app.css — 基础层（reset / 排版 / 布局 / 顶栏）
   ========================================================================= */

*, *::before, *::after { box-sizing: border-box; }

html, body { margin: 0; padding: 0; }

body {
  font-family: var(--font-sans);
  background: var(--bg);
  background-image: var(--bg-grad);
  background-attachment: fixed;
  color: var(--text);
  min-height: 100vh;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  transition: background-color var(--dur) var(--ease), color var(--dur) var(--ease);
}

a { color: var(--brand-1); text-decoration: none; transition: color var(--dur-fast); }
a:hover { color: var(--brand-2); }

h1, h2, h3, h4 { margin: 0; font-weight: 700; letter-spacing: -0.01em; color: var(--text); }

.muted { color: var(--muted); font-size: 12.5px; }

.app-shell { max-width: 1480px; margin: 0 auto; padding: 22px clamp(14px, 3vw, 34px) 60px; }

/* —— 顶栏 —— */
.topbar {
  display: flex; align-items: center; gap: 14px; flex-wrap: wrap;
  margin: 0 0 18px;
  padding: 12px 16px;
  background: color-mix(in srgb, var(--surface) 78%, transparent);
  backdrop-filter: saturate(160%) blur(14px);
  -webkit-backdrop-filter: saturate(160%) blur(14px);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-sm);
}
.topbar .brand {
  display: flex; align-items: center; gap: 10px; font-weight: 800; font-size: 16px;
}
.topbar .brand .logo {
  width: 34px; height: 34px; border-radius: 10px;
  display: grid; place-items: center;
  background: var(--brand-grad); color: #fff; font-size: 17px;
  box-shadow: var(--shadow-brand);
}
.topbar .spacer { flex: 1; }
.topbar .host-pill {
  font: 12px var(--font-mono); color: var(--muted);
  padding: 5px 10px; border-radius: var(--r-pill);
  background: var(--surface-3); border: 1px solid var(--border);
}

/* —— 主题切换按钮 —— */
.theme-toggle {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 7px 12px; border-radius: var(--r-pill);
  border: 1px solid var(--border); background: var(--surface-3); color: var(--text-soft);
  cursor: pointer; font-size: 13px;
  transition: all var(--dur-fast) var(--ease);
}
.theme-toggle:hover { color: var(--brand-1); border-color: var(--brand-1); transform: translateY(-1px); }

/* —— 卡片 —— */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: 18px;
  margin: 0 0 16px;
  box-shadow: var(--shadow-sm);
  animation: rise var(--dur-slow) var(--ease-out) both;
}
.card .card-head {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  margin-bottom: 14px; flex-wrap: wrap;
}
.card .card-head h3 { font-size: 15.5px; display: flex; align-items: center; gap: 8px; }
.card .card-head .head-actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.list-title-row { display: flex; align-items: flex-start; gap: 12px; flex: 1 1 680px; flex-wrap: wrap; }
.list-title-row h3 { padding-top: 9px; }
.email-search-form {
  width: min(760px, 100%); display: grid; grid-template-columns: minmax(280px, 1fr) auto;
  gap: 8px; align-items: stretch;
}
.email-search {
  min-height: 76px; display: flex; align-items: flex-start; gap: 8px;
  padding: 9px 10px; border: 1px solid var(--border); border-radius: var(--r-md);
  background: var(--surface); color: var(--muted);
  transition: border-color var(--dur-fast), box-shadow var(--dur-fast);
}
.email-search:focus-within { border-color: var(--brand-1); box-shadow: 0 0 0 3px var(--brand-ring); }
.email-search-icon { font-size: 17px; line-height: 1.4; }
.email-search textarea {
  min-width: 0; width: 100%; min-height: 56px; max-height: 190px; flex: 1; padding: 0; resize: vertical;
  border: 0; outline: 0; background: transparent; color: var(--text);
  font: 13px/1.45 var(--font-mono);
}
.email-search textarea::placeholder { color: var(--muted); font-family: var(--font-sans); }
.email-search-actions { display: flex; flex-direction: column; gap: 7px; }
.email-search-actions .btn { min-width: 72px; flex: 1; }
.email-search-hint { grid-column: 1 / -1; color: var(--muted); font-size: 11.5px; }
.list-filters { display: flex; align-items: center; justify-content: flex-end; gap: 10px; flex-wrap: wrap; }
.list-filter { display: inline-flex; align-items: center; gap: 6px; color: var(--muted); font-size: 12.5px; white-space: nowrap; }
.filter-result { color: var(--muted); font-size: 12.5px; white-space: nowrap; }

@keyframes rise {
  from { opacity: 0; transform: translateY(12px); }
  to   { opacity: 1; transform: translateY(0); }
}
/* 卡片错峰入场 */
.card:nth-child(1) { animation-delay: 0ms; }
.card:nth-child(2) { animation-delay: 60ms; }
.card:nth-child(3) { animation-delay: 120ms; }
.card:nth-child(4) { animation-delay: 180ms; }

/* —— 工具栏（导入区）—— */
.toolbar { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.toolbar .hint { color: var(--muted); font-size: 12.5px; }

/* —— 文件选择 —— */
.file-drop {
  position: relative;
  display: inline-flex; align-items: center; gap: 8px;
  padding: 9px 14px; border-radius: var(--r-md);
  border: 1.5px dashed var(--border); background: var(--surface-2);
  color: var(--text-soft); cursor: pointer; font-size: 13.5px;
  transition: all var(--dur-fast) var(--ease);
}
.file-drop:hover { border-color: var(--brand-1); color: var(--brand-1); background: var(--brand-soft); }
.file-drop input[type=file] { position: absolute; inset: 0; opacity: 0; cursor: pointer; }
.file-drop .fname { font-weight: 600; color: var(--text); }

/* 进度条 */
.progress {
  margin-top: 14px; display: none;
}
.progress.show { display: block; animation: rise var(--dur) var(--ease-out) both; }
.progress .progress-top { display: flex; justify-content: space-between; font-size: 12.5px; color: var(--text-soft); margin-bottom: 6px; }
.progress .progress-top #stage { font-weight: 600; color: var(--text); }
.progress .track {
  height: 10px; border-radius: var(--r-pill); overflow: hidden;
  background: var(--surface-3); border: 1px solid var(--border-soft);
}
.progress .bar {
  height: 100%; width: 0; border-radius: var(--r-pill);
  background: linear-gradient(90deg, #818cf8, #6366f1, #8b5cf6);
  background-size: 200% 100%;
  animation: shimmer 1.6s linear infinite;
  transition: width var(--dur) var(--ease);
}
@keyframes shimmer { to { background-position: -200% 0; } }
.progress .detail { margin-top: 7px; color: var(--muted); font-size: 12px; }

/* —— 统计卡 —— */
.stat-grid {
  display: grid; gap: 10px;
  grid-template-columns: repeat(auto-fill, minmax(132px, 1fr));
}
.stat {
  position: relative; overflow: hidden;
  padding: 12px 14px; border-radius: var(--r-md);
  background: var(--surface-2); border: 1px solid var(--border);
  transition: transform var(--dur-fast) var(--ease), box-shadow var(--dur-fast) var(--ease), border-color var(--dur-fast);
  animation: rise var(--dur-slow) var(--ease-out) both;
}
.stat:hover { transform: translateY(-2px); box-shadow: var(--shadow-md); border-color: var(--brand-ring); }
.stat .label { color: var(--muted); font-size: 11.5px; line-height: 1.1; }
.stat .value { font-weight: 800; font-size: 20px; line-height: 1.3; margin-top: 4px;
  background: var(--brand-grad); -webkit-background-clip: text; background-clip: text; color: transparent; }
.stat .value.muted-val { -webkit-text-fill-color: var(--text); color: var(--text); }
.stat::after {
  content: ""; position: absolute; right: -18px; top: -18px; width: 56px; height: 56px;
  border-radius: 50%; background: var(--brand-soft); filter: blur(8px);
}

/* —— 分页 —— */
.pager { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; margin-top: 12px; }
.pager .pg {
  min-width: 36px; text-align: center;
  padding: 6px 10px; border-radius: var(--r-sm);
  border: 1px solid var(--border); color: var(--text-soft);
  background: var(--surface); cursor: pointer; font-size: 13px;
  transition: all var(--dur-fast) var(--ease);
}
.pager .pg:hover { border-color: var(--brand-1); color: var(--brand-1); transform: translateY(-1px); }
.pager .pg.current { background: var(--brand-grad); color: #fff; border-color: transparent; box-shadow: var(--shadow-brand); }
.pager .ellipsis { color: var(--muted); padding: 0 2px; }
.perpage { display: inline-flex; align-items: center; gap: 6px; color: var(--muted); font-size: 12.5px; }

/* 响应式 */
@media (max-width: 640px) {
  .app-shell { padding: 14px 12px 48px; }
  .topbar { border-radius: var(--r-md); }
  .list-title-row, .email-search-form, .email-search { width: 100%; }
  .list-title-row h3 { padding-top: 0; }
  .email-search-form { grid-template-columns: 1fr; }
  .email-search-actions { flex-direction: row; }
  .email-search-hint { grid-column: 1; }
  .list-filters { width: 100%; justify-content: flex-start; }
  .list-filter { flex: 1 1 145px; }
  .list-filter .select { flex: 1; min-width: 0; }
}
