* { margin: 0; padding: 0; box-sizing: border-box; }

:root {
  --bg1: #4f46e5;
  --bg2: #7c3aed;
  --card: #ffffff;
  --text: #1e293b;
  --muted: #94a3b8;
  --line: #e2e8f0;
  --accent: #4f46e5;
  --danger: #dc2626;
  --ok: #059669;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  background: linear-gradient(135deg, var(--bg1) 0%, var(--bg2) 100%);
  min-height: 100vh;
  color: var(--text);
}

.view { min-height: 100vh; }
.hidden { display: none !important; }
.muted { color: var(--muted); font-size: 12px; }

/* ---------- 认证 ---------- */
#view-auth { display: flex; align-items: center; justify-content: center; padding: 24px; }
.auth-card {
  background: var(--card); border-radius: 20px; padding: 40px 36px;
  width: 100%; max-width: 420px; box-shadow: 0 25px 60px rgba(0,0,0,.25);
}
.brand { text-align: center; margin-bottom: 28px; }
.brand .logo { font-size: 42px; }
.brand h1 { font-size: 26px; letter-spacing: .5px; margin-top: 4px; }
.tagline { color: var(--muted); font-size: 13px; margin-top: 6px; }

.tabs { display: flex; background: #f1f5f9; border-radius: 10px; padding: 4px; margin-bottom: 22px; }
.tab {
  flex: 1; border: none; background: transparent; padding: 10px 0;
  font-size: 14px; border-radius: 8px; cursor: pointer; color: var(--muted); font-weight: 600;
}
.tab.active { background: #fff; color: var(--accent); box-shadow: 0 1px 4px rgba(0,0,0,.08); }

#form-auth label { display: block; margin-bottom: 16px; }
#form-auth label > span { display: block; font-size: 13px; color: var(--muted); margin-bottom: 6px; }
#form-auth input {
  width: 100%; padding: 11px 12px; border: 1.5px solid var(--line); border-radius: 10px;
  font-size: 15px; outline: none; transition: border .15s;
}
#form-auth input:focus { border-color: var(--accent); }
.input-wrap { display: flex; align-items: center; gap: 8px; }
.input-wrap input { flex: 1; min-width: 0; }
.domain-suffix { font-size: 13px; color: var(--muted); white-space: nowrap; }

.error {
  background: #fef2f2; color: var(--danger); border: 1px solid #fecaca;
  border-radius: 8px; padding: 9px 12px; font-size: 13px; margin-bottom: 14px;
}
.btn-primary {
  width: 100%; padding: 12px 0; border: none; border-radius: 10px;
  background: linear-gradient(135deg, var(--bg1), var(--bg2));
  color: #fff; font-size: 15px; font-weight: 600; cursor: pointer; transition: opacity .15s;
}
.btn-primary:hover { opacity: .9; }
.foot-note { text-align: center; color: var(--muted); font-size: 12px; margin-top: 18px; }

/* ---------- 顶栏 ---------- */
.topbar {
  display: flex; align-items: center; gap: 14px; flex-wrap: wrap;
  background: rgba(255,255,255,.12); backdrop-filter: blur(8px);
  padding: 14px 20px; color: #fff;
}
.brand-mini { font-size: 17px; white-space: nowrap; }
.addr-bar {
  flex: 1; min-width: 240px; display: flex; align-items: center; gap: 10px;
  background: rgba(255,255,255,.95); color: var(--text);
  border-radius: 10px; padding: 8px 14px;
}
.addr { font-weight: 600; font-size: 15px; word-break: break-all; }
.top-actions { display: flex; gap: 8px; }

.btn-mini {
  border: none; background: #eef2ff; color: var(--accent);
  padding: 7px 13px; border-radius: 8px; font-size: 13px; cursor: pointer; white-space: nowrap;
}
.btn-mini:hover { background: #e0e7ff; }
.btn-mini.danger { background: #fef2f2; color: var(--danger); }
.btn-mini.danger:hover { background: #fee2e2; }

/* ---------- 管理横幅 ---------- */
.admin-banner {
  display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap;
  background: #fffbeb; color: #92400e; border-bottom: 1px solid #fde68a;
  padding: 9px 20px; font-size: 13px;
}

/* ---------- 主布局 ---------- */
.layout { padding: 20px; max-width: 1200px; margin: 0 auto; }
.panel {
  background: var(--card); border-radius: 16px;
  box-shadow: 0 10px 30px rgba(0,0,0,.15); overflow: hidden;
}
.panel-head, .inbox-head {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: 16px 20px; border-bottom: 1px solid var(--line); flex-wrap: wrap;
}
.panel-head h2, .inbox-title h2 { font-size: 17px; }
.inbox-title { display: flex; align-items: baseline; gap: 10px; }
.inbox-actions { display: flex; gap: 8px; }

/* ---------- 用户表 ---------- */
.user-table { width: 100%; border-collapse: collapse; font-size: 14px; }
.user-table th, .user-table td { padding: 11px 20px; text-align: left; border-bottom: 1px solid var(--line); }
.user-table th { color: var(--muted); font-weight: 500; font-size: 12px; }
.user-table tr:last-child td { border-bottom: none; }

/* ---------- 收件箱 ---------- */
.inbox-layout { display: flex; min-height: 480px; }
.msg-list { list-style: none; width: 40%; min-width: 300px; border-right: 1px solid var(--line); max-height: 65vh; overflow-y: auto; }
.msg-list li { padding: 14px 20px; border-bottom: 1px solid var(--line); cursor: pointer; }
.msg-list li:hover { background: #f8fafc; }
.msg-list li.active { background: #eef2ff; }
.msg-list .from { font-size: 12px; color: var(--muted); }
.msg-list .subject { font-size: 14px; margin-top: 3px; font-weight: 500; word-break: break-all; }
.msg-list .row2 { display: flex; align-items: center; gap: 8px; margin-top: 5px; }
.msg-list .time { font-size: 11px; color: var(--muted); }
.code-chip {
  background: #ecfdf5; color: var(--ok); font-weight: 700; font-size: 12px;
  padding: 2px 8px; border-radius: 999px; font-family: monospace;
}
.msg-list li.empty { color: var(--muted); cursor: default; text-align: center; padding: 48px 0; }

.msg-detail { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.detail-head { padding: 18px 22px; border-bottom: 1px solid var(--line); }
.detail-head h3 { font-size: 16px; word-break: break-all; }
.meta { display: flex; gap: 14px; flex-wrap: wrap; margin-top: 7px; font-size: 13px; color: #475569; }
.code-wrap {
  margin-top: 14px; display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
  background: #ecfdf5; border: 1px dashed #6ee7b7; border-radius: 12px; padding: 10px 16px;
}
.code-wrap > span { font-size: 12px; color: var(--ok); font-weight: 600; }
.code-wrap code { font-size: 24px; font-weight: 800; letter-spacing: 3px; color: var(--ok); font-family: monospace; }
.detail-actions { margin-top: 12px; }
.detail-body { padding: 20px 22px; overflow: auto; font-size: 14px; line-height: 1.7; white-space: pre-wrap; word-break: break-word; flex: 1; max-height: 52vh; }
.detail-body iframe { width: 100%; min-height: 320px; border: none; }

/* ---------- Toast ---------- */
.toast {
  position: fixed; bottom: 28px; left: 50%; transform: translateX(-50%);
  background: #1e293b; color: #fff; padding: 10px 20px; border-radius: 10px;
  font-size: 14px; box-shadow: 0 8px 24px rgba(0,0,0,.3); z-index: 99;
}

/* ---------- 响应式 ---------- */
@media (max-width: 760px) {
  .inbox-layout { flex-direction: column; }
  .msg-list { width: 100%; max-height: 40vh; border-right: none; border-bottom: 1px solid var(--line); }
  .user-table th:nth-child(3), .user-table td:nth-child(3) { display: none; }
}

/* ---------- 提示标注 ---------- */
.warn-note {
  margin-top: 8px; text-align: center; font-size: 12px; color: #b45309;
  background: #fffbeb; border: 1px solid #fde68a; border-radius: 8px; padding: 8px 10px;
}
.notice-bar {
  background: #fffbeb; color: #92400e; font-size: 13px;
  padding: 9px 20px; border-bottom: 1px solid #fde68a;
}

/* ---------- 管理页签 ---------- */
.admin-tabs { display: flex; gap: 4px; }
.admin-tabs .tab { padding: 8px 18px; background: #f1f5f9; }
.admin-tabs .tab.active { background: #eef2ff; box-shadow: none; }

/* ---------- 邀请码 ---------- */
.invite-gen {
  display: flex; align-items: center; gap: 14px; flex-wrap: wrap;
  padding: 14px 20px; border-bottom: 1px solid var(--line); background: #f8fafc;
}
.invite-gen label { font-size: 13px; color: var(--muted); display: flex; align-items: center; gap: 6px; }
.invite-gen select, .invite-gen input {
  padding: 7px 10px; border: 1.5px solid var(--line); border-radius: 8px; font-size: 13px; outline: none;
}
.invite-gen select:focus, .invite-gen input:focus { border-color: var(--accent); }
.invite-gen input { width: 80px; }
.inv-table { font-size: 13px; }
.inv-code {
  font-family: monospace; font-size: 14px; font-weight: 700; letter-spacing: 1px;
  background: #eef2ff; color: var(--accent); padding: 3px 8px; border-radius: 6px;
}
.inv-usedup {
  background: #fef2f2; color: var(--danger); font-size: 11px;
  padding: 2px 7px; border-radius: 999px;
}

/* ---------- 加载视图 ---------- */
.loading-view { display: flex; align-items: center; justify-content: center; }
.spinner {
  width: 42px; height: 42px; border-radius: 50%;
  border: 4px solid rgba(255,255,255,.35); border-top-color: #fff;
  animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- 筛选栏 ---------- */
.filter-bar {
  display: flex; align-items: center; gap: 14px; flex-wrap: wrap;
  padding: 12px 20px; border-bottom: 1px solid var(--line); background: #f8fafc;
}
.filter-bar label { font-size: 13px; color: var(--muted); display: flex; align-items: center; gap: 6px; }
.filter-bar select { padding: 7px 10px; border: 1.5px solid var(--line); border-radius: 8px; font-size: 13px; outline: none; }
.filter-bar select:focus { border-color: var(--accent); }
