/* ================================================================== */
/*  临时邮箱平台 · 灰白配色 + 卡片布局                                  */
/*  design tokens                                                      */
/* ================================================================== */
:root {
  --bg: #f5f6f8;
  --bg-soft: #eef0f3;
  --card: #ffffff;
  --border: #e5e7eb;
  --border-strong: #d1d5db;
  --text: #1a1a1a;
  --text-dim: #6b7280;
  --text-mute: #9ca3af;
  --accent: #4f46e5;
  --accent-hover: #4338ca;
  --accent-soft: #eef2ff;
  --success: #10b981;
  --success-soft: #ecfdf5;
  --danger: #ef4444;
  --danger-soft: #fef2f2;
  --warn: #f59e0b;
  --warn-soft: #fffbeb;
  --radius: 14px;
  --radius-sm: 10px;
  --shadow-sm: 0 1px 2px rgba(0,0,0,0.04), 0 1px 3px rgba(0,0,0,0.06);
  --shadow: 0 1px 3px rgba(0,0,0,0.06), 0 4px 12px rgba(0,0,0,0.05);
  --shadow-hover: 0 4px 8px rgba(0,0,0,0.06), 0 12px 28px rgba(0,0,0,0.08);
  --t: 0.2s cubic-bezier(.4,0,.2,1);
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { min-height: 100%; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--accent); text-decoration: none; }
a:hover { color: var(--accent-hover); }

/* ---- topbar ---- */
.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 28px; flex-wrap: wrap; gap: 12px;
  background: rgba(255,255,255,0.85);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
}
.brand { display: flex; align-items: center; gap: 12px; }
.logo { font-size: 28px; line-height: 1; filter: drop-shadow(0 2px 4px rgba(0,0,0,0.1)); }
.brand-text h1 { font-size: 18px; font-weight: 700; letter-spacing: .3px; }
.brand-text p { font-size: 12px; color: var(--text-dim); }
.topbar-right { display: flex; align-items: center; gap: 10px; }
.nav-link { font-size: 13px; color: var(--text-dim); padding: 6px 10px; border-radius: 8px; transition: var(--t); }
.nav-link:hover { background: var(--bg-soft); color: var(--text); }
.user-chip {
  font-size: 13px; font-weight: 600; color: var(--text);
  background: var(--accent-soft); padding: 6px 12px; border-radius: 999px;
}

/* ---- layout ---- */
.container {
  max-width: 880px; margin: 0 auto; padding: 28px 18px 60px;
  display: flex; flex-direction: column; gap: 20px;
}

/* ---- card ---- */
.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 22px;
  box-shadow: var(--shadow-sm);
  transition: box-shadow var(--t), transform var(--t);
}
.card:hover { box-shadow: var(--shadow); }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 14px; flex-wrap: wrap; }
.card-head h2, .card h3 { font-size: 16px; font-weight: 700; }
.card-label { font-size: 12px; color: var(--text-dim); margin-bottom: 10px; text-transform: uppercase; letter-spacing: .5px; }

/* ---- email card ---- */
.email-row { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.email-display {
  flex: 1 1 280px; min-width: 0;
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  background: var(--bg-soft);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 14px 16px; cursor: pointer;
  transition: var(--t);
}
.email-display:hover { border-color: var(--accent); background: var(--accent-soft); }
.email-text {
  font-family: "JetBrains Mono", "SF Mono", Consolas, monospace;
  font-size: 16px; font-weight: 600; color: var(--accent);
  word-break: break-all;
}
.email-text.loading { color: var(--text-mute); }
.copy-icon { font-size: 16px; opacity: .5; flex-shrink: 0; }

.custom-row { display: flex; gap: 10px; margin-top: 14px; flex-wrap: wrap; }
.input {
  flex: 1 1 200px; min-width: 0;
  background: var(--card); border: 1.5px solid var(--border); color: var(--text);
  border-radius: var(--radius-sm); padding: 10px 14px; font-size: 14px; font-family: inherit;
  transition: var(--t);
}
.input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.input::placeholder { color: var(--text-mute); }
.email-meta { margin-top: 12px; font-size: 12px; color: var(--text-dim); min-height: 16px; }

/* ---- buttons ---- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  border: 1.5px solid var(--border-strong); background: var(--card);
  color: var(--text); font-size: 14px; font-weight: 600; font-family: inherit;
  padding: 10px 16px; border-radius: var(--radius-sm); cursor: pointer;
  transition: var(--t); white-space: nowrap; user-select: none;
}
.btn:hover { background: var(--bg-soft); border-color: var(--text-mute); }
.btn:active { transform: scale(0.97); }
.btn:disabled { opacity: .5; cursor: not-allowed; transform: none; }
.btn-sm { padding: 6px 12px; font-size: 13px; }
.btn-xs { padding: 4px 10px; font-size: 12px; }
.btn-primary {
  background: var(--accent); border-color: var(--accent); color: #fff;
  box-shadow: 0 1px 2px rgba(79,70,229,0.3);
}
.btn-primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); }
.btn-ghost { background: transparent; border-color: var(--border); }
.btn-ghost:hover { background: var(--bg-soft); }
.btn-danger { border-color: var(--danger); color: var(--danger); background: transparent; }
.btn-danger:hover { background: var(--danger-soft); }
.btn-block { width: 100%; }

/* ---- inbox ---- */
.count {
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 12px; background: var(--accent); color: #fff;
  border-radius: 999px; padding: 0 8px; min-width: 22px; height: 20px; font-weight: 700;
}
.inbox-controls { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.auto-status { font-size: 12px; color: var(--text-dim); display: inline-flex; align-items: center; gap: 6px; }
.countdown { color: var(--accent); font-variant-numeric: tabular-nums; min-width: 12px; display: inline-block; font-weight: 600; }
.dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; }
.dot-live { background: var(--success); box-shadow: 0 0 0 0 rgba(16,185,129,0.5); animation: pulse 1.8s infinite; }
.dot-off { background: var(--text-mute); animation: none; }
@keyframes pulse { 0%{box-shadow:0 0 0 0 rgba(16,185,129,0.5)} 70%{box-shadow:0 0 0 6px rgba(16,185,129,0)} 100%{box-shadow:0 0 0 0 rgba(16,185,129,0)} }
.inbox-meta { font-size: 12px; color: var(--text-dim); margin: 10px 0 8px; }
.inbox-list { display: flex; flex-direction: column; gap: 8px; max-height: 56vh; overflow-y: auto; padding-right: 4px; }
.inbox-list::-webkit-scrollbar { width: 8px; }
.inbox-list::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: 8px; }
.empty-state { text-align: center; color: var(--text-mute); padding: 40px 16px; }
.empty-icon { font-size: 40px; margin-bottom: 8px; }

.msg {
  display: flex; gap: 12px; align-items: flex-start;
  background: var(--card); border: 1px solid var(--border);
  border-radius: var(--radius-sm); padding: 13px 15px; cursor: pointer;
  transition: var(--t); border-left: 3px solid transparent;
}
.msg:hover { border-color: var(--border-strong); border-left-color: var(--accent); background: var(--accent-soft); transform: translateX(2px); }
.msg.unread { border-left-color: var(--accent); background: var(--accent-soft); }
.msg.unread .msg-subject { font-weight: 700; }
.msg-icon { font-size: 20px; flex-shrink: 0; margin-top: 2px; }
.msg-main { flex: 1; min-width: 0; }
.msg-top { display: flex; justify-content: space-between; gap: 10px; align-items: baseline; }
.msg-from { font-size: 13px; color: var(--text); font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 60%; }
.msg-time { font-size: 11px; color: var(--text-mute); white-space: nowrap; flex-shrink: 0; }
.msg-subject { font-size: 14px; color: var(--text); margin-top: 2px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.msg-snippet { font-size: 12px; color: var(--text-dim); margin-top: 3px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.msg-code { font-size: 12px; color: var(--warn); margin-top: 4px; font-family: monospace; font-weight: 700; background: var(--warn-soft); display: inline-block; padding: 1px 8px; border-radius: 6px; }

/* ---- history ---- */
.history-list { display: flex; flex-direction: column; gap: 6px; max-height: 200px; overflow-y: auto; }
.hist-item { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 9px 12px; border: 1px solid var(--border); border-radius: var(--radius-sm); cursor: pointer; transition: var(--t); }
.hist-item:hover { border-color: var(--accent); background: var(--accent-soft); }
.hist-item.active { border-color: var(--accent); background: var(--accent-soft); }
.hist-addr { font-family: monospace; font-size: 13px; font-weight: 600; }
.hist-time { font-size: 11px; color: var(--text-mute); }

/* ---- switch ---- */
.switch { position: relative; display: inline-block; width: 40px; height: 22px; }
.switch input { opacity: 0; width: 0; height: 0; }
.slider { position: absolute; cursor: pointer; inset: 0; background: var(--border-strong); border-radius: 999px; transition: var(--t); }
.slider::before { content: ""; position: absolute; height: 16px; width: 16px; left: 3px; top: 3px; background: #fff; border-radius: 50%; transition: var(--t); box-shadow: 0 1px 2px rgba(0,0,0,0.2); }
.switch input:checked + .slider { background: var(--accent); }
.switch input:checked + .slider::before { transform: translateX(18px); }

/* ---- tabs (shared) ---- */
.tabs { display: flex; gap: 4px; margin: 0 0 18px; border-bottom: 1.5px solid var(--border); }
.tab { background: none; border: none; color: var(--text-dim); font-size: 14px; font-weight: 600; cursor: pointer; padding: 10px 18px; font-family: inherit; position: relative; transition: var(--t); }
.tab:hover { color: var(--text); }
.tab.tab-active { color: var(--accent); }
.tab.tab-active::after { content: ""; position: absolute; left: 12px; right: 12px; bottom: -2px; height: 2px; background: var(--accent); border-radius: 2px; }

/* ---- modal ---- */
.modal-overlay {
  position: fixed; inset: 0; z-index: 100;
  background: rgba(17,24,39,0.5); backdrop-filter: blur(4px);
  display: flex; align-items: center; justify-content: center; padding: 18px;
  animation: fadeIn .15s ease;
}
.modal-overlay[hidden] { display: none; }
@keyframes fadeIn { from{opacity:0} to{opacity:1} }
.modal {
  background: var(--card); border-radius: var(--radius);
  width: 100%; max-width: 760px; max-height: 90vh;
  display: flex; flex-direction: column; box-shadow: var(--shadow-hover); overflow: hidden;
  animation: slideUp .2s cubic-bezier(.4,0,.2,1);
}
@keyframes slideUp { from{opacity:0; transform: translateY(16px)} to{opacity:1; transform: translateY(0)} }
.modal-header { display: flex; align-items: center; justify-content: space-between; padding: 16px 20px; border-bottom: 1px solid var(--border); }
.modal-header h3 { font-size: 16px; font-weight: 700; word-break: break-word; }
.modal-close { background: none; border: none; color: var(--text-mute); font-size: 18px; cursor: pointer; padding: 4px 8px; border-radius: 6px; transition: var(--t); }
.modal-close:hover { background: var(--bg-soft); color: var(--text); }
.modal-meta { padding: 10px 20px; font-size: 12px; color: var(--text-dim); border-bottom: 1px solid var(--border); }
.modal-meta div { margin: 2px 0; word-break: break-all; }
.modal-tabs { display: flex; gap: 4px; padding: 0 16px; }
.modal-body { flex: 1; overflow: hidden; display: flex; }
.tab-pane { display: none; flex: 1; overflow: auto; padding: 16px 20px; }
.tab-pane.tab-pane-active { display: block; }
.tab-pane pre { white-space: pre-wrap; word-break: break-word; font-size: 12px; font-family: Consolas, monospace; color: var(--text-dim); }
#frameHtml, #frameBody { width: 100%; height: 100%; min-height: 320px; border: none; background: #fff; }
.modal-footer { display: flex; justify-content: space-between; gap: 10px; padding: 12px 20px; border-top: 1px solid var(--border); }

/* ---- toast ---- */
.toast {
  position: fixed; bottom: 26px; left: 50%; transform: translateX(-50%) translateY(20px);
  background: var(--text); color: #fff;
  padding: 11px 20px; border-radius: var(--radius-sm); font-size: 14px; z-index: 200;
  box-shadow: var(--shadow-hover); opacity: 0; transition: opacity .2s, transform .2s; pointer-events: none;
  max-width: 90vw;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.toast.error { background: var(--danger); }
.toast.ok { background: var(--success); }

/* ---- footer ---- */
.footer { text-align: center; color: var(--text-mute); font-size: 12px; padding: 10px 16px 30px; }

/* ================================================================== */
/*  Auth page                                                          */
/* ================================================================== */
.auth-body {
  min-height: 100vh; display: flex; align-items: center; justify-content: center;
  padding: 20px; background:
    radial-gradient(900px 500px at 80% -10%, var(--accent-soft) 0%, transparent 60%),
    radial-gradient(700px 400px at -10% 110%, var(--bg-soft) 0%, transparent 55%),
    var(--bg);
}
.auth-card {
  width: 100%; max-width: 400px;
  background: var(--card); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 32px 28px; box-shadow: var(--shadow);
}
.auth-brand { text-align: center; margin-bottom: 20px; }
.auth-brand .logo { font-size: 40px; }
.auth-brand h1 { font-size: 20px; font-weight: 700; margin-top: 6px; }
.auth-brand p { font-size: 13px; color: var(--text-dim); margin-top: 2px; }
.auth-form { margin-top: 18px; }
.auth-form .btn-block { margin-top: 8px; }
.auth-hint { text-align: center; font-size: 12px; color: var(--text-dim); margin-top: 16px; }

/* floating-label field */
.field { position: relative; margin-bottom: 16px; }
.field input {
  width: 100%; background: var(--bg-soft); border: 1.5px solid var(--border); color: var(--text);
  border-radius: var(--radius-sm); padding: 16px 14px 8px; font-size: 14px; font-family: inherit;
  transition: var(--t);
}
.field input:focus { outline: none; border-color: var(--accent); background: var(--card); box-shadow: 0 0 0 3px var(--accent-soft); }
.field label {
  position: absolute; left: 14px; top: 14px; color: var(--text-mute);
  font-size: 14px; pointer-events: none; transition: var(--t); background: transparent;
}
.field input:focus + label,
.field input:not(:placeholder-shown) + label {
  top: 5px; font-size: 11px; color: var(--accent); font-weight: 600;
}
.toggle-pw { position: absolute; right: 10px; top: 50%; transform: translateY(-50%); background: none; border: none; cursor: pointer; font-size: 16px; opacity: .6; padding: 4px; }
.toggle-pw:hover { opacity: 1; }

/* ================================================================== */
/*  Admin layout                                                       */
/* ================================================================== */
.admin-body { display: flex; min-height: 100vh; }
.admin-side {
  width: 230px; flex-shrink: 0;
  background: var(--card); border-right: 1px solid var(--border);
  padding: 20px 14px; display: flex; flex-direction: column; gap: 18px;
  position: sticky; top: 0; height: 100vh;
}
.admin-brand { display: flex; align-items: center; gap: 10px; padding: 4px 6px; }
.admin-brand .logo { font-size: 26px; }
.admin-brand h1 { font-size: 15px; font-weight: 700; }
.admin-brand p { font-size: 11px; color: var(--text-dim); }
.admin-nav { display: flex; flex-direction: column; gap: 4px; }
.nav-item {
  display: flex; align-items: center; gap: 8px;
  padding: 10px 12px; border-radius: var(--radius-sm); color: var(--text-dim);
  font-size: 14px; font-weight: 500; cursor: pointer; transition: var(--t);
}
.nav-item:hover { background: var(--bg-soft); color: var(--text); }
.nav-item.active { background: var(--accent); color: #fff; }
.admin-side-footer { margin-top: auto; display: flex; flex-direction: column; gap: 8px; padding-top: 14px; border-top: 1px solid var(--border); }
.admin-main { flex: 1; padding: 28px; overflow-x: auto; }
.view { display: none; animation: fadeIn .2s ease; }
.view.active { display: block; }
.view-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 18px; }
.view-head h2 { font-size: 20px; font-weight: 700; }

/* stat grid */
.stat-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 14px; margin-bottom: 20px; }
.stat-card { padding: 18px; position: relative; }
.stat-card:hover { transform: translateY(-2px); box-shadow: var(--shadow-hover); }
.stat-icon { position: absolute; right: 16px; top: 16px; font-size: 22px; opacity: .4; }
.stat-val { font-size: 28px; font-weight: 800; color: var(--text); line-height: 1.1; }
.stat-label { font-size: 13px; color: var(--text-dim); margin-top: 2px; }
.stat-sub { font-size: 11px; color: var(--text-mute); margin-top: 6px; }

/* chart */
.chart-card { margin-bottom: 20px; }
.chart { height: 180px; }
.bars { display: flex; align-items: flex-end; gap: 10px; height: 140px; padding-top: 10px; }
.bar-wrap { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 6px; height: 100%; justify-content: flex-end; }
.bar { width: 100%; max-width: 40px; background: linear-gradient(180deg, var(--accent), #818cf8); border-radius: 6px 6px 0 0; transition: height var(--t); min-height: 4px; }
.bar:hover { filter: brightness(1.1); }
.bar-label { font-size: 11px; color: var(--text-mute); }

/* top senders */
.top-list { display: flex; flex-direction: column; gap: 4px; }
.top-item { display: flex; align-items: center; gap: 12px; padding: 9px 10px; border-radius: var(--radius-sm); transition: var(--t); }
.top-item:hover { background: var(--bg-soft); }
.rank { width: 24px; height: 24px; flex-shrink: 0; display: inline-flex; align-items: center; justify-content: center; background: var(--bg-soft); border-radius: 50%; font-size: 12px; font-weight: 700; color: var(--text-dim); }
.top-name { flex: 1; font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.top-count { font-size: 12px; font-weight: 700; color: var(--accent); }
.empty-inline { text-align: center; color: var(--text-mute); font-size: 13px; padding: 20px; }

/* toolbar + table */
.toolbar { display: flex; gap: 10px; margin-bottom: 14px; flex-wrap: wrap; }
.toolbar .input { flex: 1; max-width: 360px; }
.table-card { padding: 0; overflow: hidden; }
.table { width: 100%; border-collapse: collapse; font-size: 13px; }
.table th { text-align: left; padding: 12px 14px; background: var(--bg-soft); color: var(--text-dim); font-weight: 600; font-size: 12px; white-space: nowrap; border-bottom: 1px solid var(--border); }
.table td { padding: 11px 14px; border-bottom: 1px solid var(--border); color: var(--text); vertical-align: middle; }
.table tbody tr { transition: var(--t); }
.table tbody tr:hover { background: var(--bg-soft); }
.table tbody tr:last-child td { border-bottom: none; }
.mono { font-family: Consolas, monospace; font-size: 12px; }
.empty-row { text-align: center; color: var(--text-mute); padding: 30px; }
.row-actions { display: flex; gap: 6px; flex-wrap: wrap; }

/* badges */
.badge { display: inline-flex; align-items: center; font-size: 11px; font-weight: 600; padding: 2px 9px; border-radius: 999px; }
.badge-admin { background: var(--accent-soft); color: var(--accent); }
.badge-user { background: var(--bg-soft); color: var(--text-dim); }
.badge-active { background: var(--success-soft); color: var(--success); }
.badge-disabled { background: var(--danger-soft); color: var(--danger); }
.msg-code-inline { font-family: monospace; background: var(--warn-soft); color: var(--warn); padding: 0 6px; border-radius: 4px; font-size: 11px; }

/* pager */
.pager { display: flex; align-items: center; gap: 10px; padding: 12px 14px; border-top: 1px solid var(--border); flex-wrap: wrap; }
.pager-info { font-size: 12px; color: var(--text-dim); margin-right: auto; }

/* ---- responsive ---- */
@media (max-width: 760px) {
  .admin-body { flex-direction: column; }
  .admin-side { width: 100%; height: auto; position: relative; flex-direction: row; align-items: center; overflow-x: auto; }
  .admin-nav { flex-direction: row; }
  .admin-side-footer { margin-top: 0; border-top: none; padding-top: 0; flex-direction: row; }
  .admin-main { padding: 18px; }
}
@media (max-width: 600px) {
  .topbar { padding: 12px 16px; }
  .brand-text h1 { font-size: 16px; }
  .email-text { font-size: 14px; }
  .msg-from { max-width: 100%; }
  .modal-body { flex-direction: column; }
  #frameHtml, #frameBody { min-height: 240px; }
  .stat-grid { grid-template-columns: repeat(2, 1fr); }
  .table { font-size: 12px; }
  .table th, .table td { padding: 8px 10px; }
}
