/* ============ GoMail Admin UI ============ */
:root {
  --primary: #4f46e5;
  --primary-hover: #4338ca;
  --primary-soft: #eef2ff;
  --bg: #f4f5fa;
  --surface: #ffffff;
  --text: #1e2235;
  --text-2: #6b7280;
  --border: #e5e7f0;
  --success: #10b981;
  --danger: #ef4444;
  --warning: #f59e0b;
  --radius: 12px;
  --shadow: 0 1px 3px rgba(30, 34, 53, .06), 0 4px 16px rgba(30, 34, 53, .06);
  --shadow-lg: 0 8px 30px rgba(30, 34, 53, .14);
  --sidebar-w: 248px;
}
* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
body {
  font-family: "Inter", "PingFang SC", "Microsoft YaHei", -apple-system, "Segoe UI", sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  -webkit-font-smoothing: antialiased;
}
.hidden { display: none !important; }
a { text-decoration: none; color: inherit; }

/* ---------- 登录页 ---------- */
.login-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background:
    radial-gradient(1200px 500px at 80% -10%, rgba(99, 102, 241, .25), transparent),
    radial-gradient(900px 500px at 10% 110%, rgba(16, 185, 129, .18), transparent),
    linear-gradient(160deg, #0f1123 0%, #1a1d3a 100%);
  padding: 24px;
}
.login-card {
  width: 100%;
  max-width: 400px;
  background: var(--surface);
  border-radius: 20px;
  padding: 40px 36px 28px;
  box-shadow: 0 24px 60px rgba(0, 0, 0, .35);
}
.login-brand { text-align: center; margin-bottom: 28px; }
.login-brand h1 { font-size: 26px; margin: 12px 0 4px; letter-spacing: .5px; }
.login-brand p { color: var(--text-2); font-size: 13px; }
.logo-mark { display: inline-flex; }
#login-form label { display: block; font-size: 13px; font-weight: 500; margin-bottom: 16px; color: var(--text); }
#login-form input {
  display: block; width: 100%; margin-top: 6px;
  padding: 11px 14px; border: 1.5px solid var(--border); border-radius: 10px;
  font-size: 14px; transition: border-color .15s, box-shadow .15s;
}
#login-form input:focus {
  outline: none; border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(79, 70, 229, .12);
}
.login-foot { text-align: center; color: var(--text-2); font-size: 12px; margin-top: 22px; }

/* ---------- 按钮 ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 9px 18px; border: none; border-radius: 10px;
  font-size: 14px; font-weight: 500; cursor: pointer;
  transition: all .15s; font-family: inherit;
}
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-hover); transform: translateY(-1px); }
.btn-block { width: 100%; padding: 12px; font-size: 15px; }
.btn-ghost { background: transparent; color: var(--text-2); border: 1.5px solid var(--border); }
.btn-ghost:hover { border-color: var(--primary); color: var(--primary); }
.btn-danger { background: #fef2f2; color: var(--danger); }
.btn-danger:hover { background: var(--danger); color: #fff; }
.btn-sm { padding: 5px 12px; font-size: 12.5px; border-radius: 8px; }
.btn:disabled { opacity: .55; cursor: not-allowed; transform: none !important; }
.icon-btn {
  background: none; border: none; cursor: pointer; color: var(--text-2);
  padding: 6px; border-radius: 8px; display: inline-flex; transition: all .15s;
}
.icon-btn:hover { background: rgba(0, 0, 0, .05); color: var(--text); }

/* ---------- 布局 ---------- */
.app { display: flex; min-height: 100vh; }
.sidebar {
  width: var(--sidebar-w);
  background: #14172e;
  color: #c7c9e0;
  display: flex; flex-direction: column;
  position: fixed; top: 0; bottom: 0; left: 0; z-index: 40;
  transition: transform .25s ease;
}
.side-brand {
  display: flex; align-items: center; gap: 10px;
  padding: 22px 24px; font-size: 19px; font-weight: 700; color: #fff;
  letter-spacing: .5px;
}
.side-nav { flex: 1; padding: 8px 14px; }
.nav-item {
  display: flex; align-items: center; gap: 12px;
  padding: 11px 14px; margin-bottom: 4px;
  border-radius: 10px; font-size: 14px; font-weight: 500;
  transition: all .15s; color: #a6a9c8;
}
.nav-item:hover { background: rgba(255, 255, 255, .06); color: #fff; }
.nav-item.active { background: var(--primary); color: #fff; box-shadow: 0 4px 14px rgba(79, 70, 229, .4); }
.side-user {
  display: flex; align-items: center; gap: 10px;
  padding: 16px 20px; border-top: 1px solid rgba(255, 255, 255, .08);
}
.avatar {
  width: 36px; height: 36px; border-radius: 50%;
  background: linear-gradient(135deg, #6366f1, #8b5cf6);
  color: #fff; display: flex; align-items: center; justify-content: center;
  font-weight: 600; font-size: 15px; flex-shrink: 0;
}
.side-user-info { flex: 1; min-width: 0; }
.side-user-name { font-size: 13.5px; font-weight: 600; color: #fff; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.side-user-mail { font-size: 11.5px; color: #8b8eae; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.side-user .icon-btn { color: #8b8eae; }
.side-user .icon-btn:hover { background: rgba(255, 255, 255, .08); color: #fff; }

.main { flex: 1; margin-left: var(--sidebar-w); display: flex; flex-direction: column; min-width: 0; }
.topbar {
  height: 60px; background: var(--surface);
  display: flex; align-items: center; gap: 14px;
  padding: 0 28px; border-bottom: 1px solid var(--border);
  position: sticky; top: 0; z-index: 20;
}
.topbar h2 { font-size: 17px; font-weight: 600; }
.topbar-right { margin-left: auto; display: flex; align-items: center; gap: 12px; }
.status-dot { display: inline-flex; align-items: center; gap: 7px; font-size: 12.5px; color: var(--text-2); }
.status-dot i {
  width: 8px; height: 8px; border-radius: 50%; background: var(--success);
  box-shadow: 0 0 0 3px rgba(16, 185, 129, .18);
  animation: pulse 2s infinite;
}
@keyframes pulse { 50% { box-shadow: 0 0 0 6px rgba(16, 185, 129, 0); } }
.menu-btn { display: none; }
.content { padding: 28px; flex: 1; max-width: 1280px; width: 100%; margin: 0 auto; }

/* ---------- 卡片 & 仪表盘 ---------- */
.stat-grid {
  display: grid; gap: 18px;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  margin-bottom: 26px;
}
.stat-card {
  background: var(--surface); border-radius: var(--radius);
  padding: 20px 22px; box-shadow: var(--shadow);
  display: flex; align-items: center; gap: 16px;
  transition: transform .15s, box-shadow .15s;
}
.stat-card:hover { transform: translateY(-2px); box-shadow: var(--shadow-lg); }
.stat-icon {
  width: 46px; height: 46px; border-radius: 12px; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
}
.stat-icon svg { width: 22px; height: 22px; }
.stat-info .num { font-size: 24px; font-weight: 700; line-height: 1.15; }
.stat-info .label { font-size: 12.5px; color: var(--text-2); margin-top: 2px; }

.panel {
  background: var(--surface); border-radius: var(--radius);
  box-shadow: var(--shadow); margin-bottom: 22px; overflow: hidden;
}
.panel-head {
  display: flex; align-items: center; gap: 12px;
  padding: 16px 22px; border-bottom: 1px solid var(--border);
}
.panel-head h3 { font-size: 15px; font-weight: 600; }
.panel-head .spacer { flex: 1; }
.panel-body { padding: 22px; }

/* ---------- 表格 ---------- */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
th {
  text-align: left; padding: 12px 16px; color: var(--text-2);
  font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: .4px;
  border-bottom: 1px solid var(--border); background: #fafbfd; white-space: nowrap;
}
td { padding: 13px 16px; border-bottom: 1px solid #f1f2f8; vertical-align: middle; }
tr:last-child td { border-bottom: none; }
tbody tr { transition: background .12s; }
tbody tr:hover { background: #fafbff; }
.badge {
  display: inline-flex; align-items: center; padding: 3px 10px;
  border-radius: 999px; font-size: 12px; font-weight: 500;
}
.badge-green { background: #ecfdf5; color: #059669; }
.badge-red { background: #fef2f2; color: #dc2626; }
.badge-blue { background: var(--primary-soft); color: var(--primary); }
.badge-gray { background: #f3f4f6; color: var(--text-2); }
.row-actions { display: flex; gap: 6px; }
.mail-cell { max-width: 260px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mail-subject {
  display: inline-block; max-width: 100%; overflow: hidden;
  text-overflow: ellipsis; white-space: nowrap; vertical-align: bottom;
  color: var(--text); text-decoration: none; cursor: pointer;
}
.mail-subject:hover { color: var(--primary); }
.unread-dot {
  display: inline-block; width: 8px; height: 8px; border-radius: 50%;
  background: var(--primary); margin-right: 8px;
}

/* ---------- 搜索/工具条 ---------- */
.toolbar { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.search-box { position: relative; }
.search-box input {
  padding: 9px 14px 9px 36px; border: 1.5px solid var(--border);
  border-radius: 10px; font-size: 13.5px; width: 240px; font-family: inherit;
  transition: border-color .15s, box-shadow .15s;
}
.search-box input:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px rgba(79, 70, 229, .1); }
.search-box svg { position: absolute; left: 11px; top: 50%; transform: translateY(-50%); color: var(--text-2); }
select.input, input.input {
  padding: 9px 12px; border: 1.5px solid var(--border); border-radius: 10px;
  font-size: 13.5px; font-family: inherit; background: #fff;
}
select.input:focus, input.input:focus { outline: none; border-color: var(--primary); }

/* ---------- 分页 ---------- */
.pagination { display: flex; align-items: center; gap: 6px; padding: 14px 22px; justify-content: flex-end; font-size: 13px; color: var(--text-2); }
.pagination button {
  min-width: 30px; height: 30px; border: 1px solid var(--border); background: #fff;
  border-radius: 8px; cursor: pointer; font-size: 13px; color: var(--text);
  font-family: inherit; transition: all .12s;
}
.pagination button:hover:not(:disabled) { border-color: var(--primary); color: var(--primary); }
.pagination button.cur { background: var(--primary); border-color: var(--primary); color: #fff; }
.pagination button:disabled { opacity: .4; cursor: not-allowed; }

/* ---------- 弹窗 ---------- */
.modal-mask {
  position: fixed; inset: 0; background: rgba(15, 17, 35, .5);
  backdrop-filter: blur(3px); z-index: 100;
  display: flex; align-items: center; justify-content: center; padding: 20px;
  animation: fadeIn .15s;
}
@keyframes fadeIn { from { opacity: 0; } }
.modal {
  background: var(--surface); border-radius: 16px; box-shadow: var(--shadow-lg);
  width: 100%; max-width: 460px; max-height: 88vh; overflow-y: auto;
  animation: slideUp .18s ease;
}
.modal.wide { max-width: 720px; }
@keyframes slideUp { from { transform: translateY(16px); opacity: 0; } }
.modal-head {
  display: flex; align-items: center; padding: 18px 24px 0;
}
.modal-head h3 { font-size: 16px; font-weight: 600; flex: 1; }
.modal-body { padding: 18px 24px 24px; }
.modal-foot { display: flex; justify-content: flex-end; gap: 10px; padding: 0 24px 22px; }
.form-row { margin-bottom: 16px; }
.form-row label { display: block; font-size: 13px; font-weight: 500; margin-bottom: 6px; }
.form-row input, .form-row select {
  width: 100%; padding: 10px 13px; border: 1.5px solid var(--border);
  border-radius: 10px; font-size: 14px; font-family: inherit;
}
.form-row input:focus, .form-row select:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px rgba(79, 70, 229, .1); }
.form-hint { font-size: 12px; color: var(--text-2); margin-top: 5px; }
.form-error {
  background: #fef2f2; color: var(--danger); font-size: 13px;
  padding: 9px 13px; border-radius: 9px; margin-bottom: 14px;
}
.switch-row { display: flex; align-items: center; justify-content: space-between; padding: 4px 0 12px; }
.switch { position: relative; width: 42px; height: 24px; flex-shrink: 0; }
.switch input { opacity: 0; width: 0; height: 0; }
.switch i {
  position: absolute; inset: 0; background: #d1d5db; border-radius: 999px;
  cursor: pointer; transition: .2s;
}
.switch i::before {
  content: ""; position: absolute; width: 18px; height: 18px; border-radius: 50%;
  background: #fff; top: 3px; left: 3px; transition: .2s; box-shadow: 0 1px 3px rgba(0, 0, 0, .2);
}
.switch input:checked + i { background: var(--primary); }
.switch input:checked + i::before { transform: translateX(18px); }

/* ---------- 邮件查看 ---------- */
.msg-meta { border-bottom: 1px solid var(--border); padding-bottom: 14px; margin-bottom: 16px; }
.msg-meta h4 { font-size: 16px; margin-bottom: 10px; }
.msg-meta .meta-line { font-size: 13px; color: var(--text-2); margin-bottom: 4px; }
.msg-meta .meta-line b { color: var(--text); font-weight: 500; }
.msg-body {
  background: #fafbfd; border: 1px solid var(--border); border-radius: 10px;
  padding: 16px; font-size: 13px; line-height: 1.7;
  white-space: pre-wrap; word-break: break-all;
  max-height: 46vh; overflow-y: auto; font-family: "SFMono-Regular", Consolas, monospace;
}

/* ---------- Toast ---------- */
#toast-wrap { position: fixed; top: 20px; right: 20px; z-index: 200; display: flex; flex-direction: column; gap: 10px; }
.toast {
  background: #1e2235; color: #fff; padding: 12px 18px; border-radius: 10px;
  font-size: 13.5px; box-shadow: var(--shadow-lg);
  display: flex; align-items: center; gap: 9px;
  animation: toastIn .25s ease; max-width: 340px;
}
.toast.success { background: #065f46; }
.toast.error { background: #991b1b; }
@keyframes toastIn { from { transform: translateX(30px); opacity: 0; } }

/* ---------- 空状态 ---------- */
.empty { text-align: center; padding: 60px 20px; color: var(--text-2); }
.empty svg { opacity: .35; margin-bottom: 14px; }
.empty p { font-size: 14px; }

/* ---------- 设置页 ---------- */
.settings-grid { display: grid; gap: 20px; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); }
.info-list { list-style: none; }
.info-list li { display: flex; justify-content: space-between; padding: 11px 0; border-bottom: 1px solid #f1f2f8; font-size: 13.5px; }
.info-list li:last-child { border-bottom: none; }
.info-list .k { color: var(--text-2); }
.info-list .v { font-weight: 500; }

/* ---------- 响应式 ---------- */
@media (max-width: 900px) {
  .sidebar { transform: translateX(-100%); }
  .sidebar.open { transform: translateX(0); box-shadow: 0 0 60px rgba(0, 0, 0, .4); }
  .main { margin-left: 0; }
  .menu-btn { display: inline-flex; }
  .content { padding: 18px 16px; }
  .topbar { padding: 0 16px; }
  .search-box input { width: 100%; }
  .toolbar { width: 100%; }
  .search-box { flex: 1; }
}
