/* AnkerYe-Mail 管理后台 · © AnkerYe */
:root {
  --sidebar: #0f172a;
  --sidebar-hover: rgba(255, 255, 255, .06);
  --primary: #4f46e5;
  --primary-hover: #4338ca;
  --bg: #f1f5f9;
  --card: #ffffff;
  --border: #e2e8f0;
  --text: #0f172a;
  --text-2: #475569;
  --text-3: #94a3b8;
  --green: #16a34a; --green-bg: #f0fdf4;
  --red: #dc2626;   --red-bg: #fef2f2;
  --amber: #d97706; --amber-bg: #fffbeb;
  --blue: #2563eb;  --blue-bg: #eff6ff;
  --purple: #9333ea;--purple-bg: #faf5ff;
  --gray: #64748b;  --gray-bg: #f1f5f9;
  --radius: 12px;
}
* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  font-size: 14px; color: var(--text); background: var(--bg);
  -webkit-font-smoothing: antialiased;
}
button { font: inherit; cursor: pointer; }
input, select, textarea { font: inherit; color: var(--text); }
a { color: var(--primary); text-decoration: none; }

/* ---------- 登录 ---------- */
#login-view {
  position: fixed; inset: 0; display: flex; align-items: center; justify-content: center;
  background: linear-gradient(135deg, #0f172a 0%, #1e293b 60%, #312e81 100%);
}
#login-view[hidden] { display: none; }
.login-card {
  width: 380px; max-width: calc(100vw - 32px); background: var(--card); border-radius: 16px;
  padding: 40px 36px 32px; box-shadow: 0 24px 64px rgba(0, 0, 0, .4);
}
.login-logo { display: flex; flex-direction: column; align-items: center; gap: 12px; margin-bottom: 28px; }
.logo-mark {
  width: 56px; height: 56px; border-radius: 16px; display: flex; align-items: center; justify-content: center;
  background: linear-gradient(135deg, #6366f1, #4338ca); color: #fff;
  box-shadow: 0 8px 20px rgba(79, 70, 229, .35);
}
.login-logo h1 { font-size: 20px; font-weight: 700; letter-spacing: .3px; }
.login-logo p { font-size: 12.5px; color: var(--text-3); }
.login-card .field { margin-bottom: 14px; }
.login-error { color: var(--red); font-size: 12.5px; min-height: 18px; margin: 4px 0 10px; text-align: center; }

/* ---------- 布局 ---------- */
#app { display: none; min-height: 100vh; }
#app.on { display: block; }
.sidebar {
  position: fixed; top: 0; left: 0; bottom: 0; width: 224px; background: var(--sidebar);
  display: flex; flex-direction: column; z-index: 40; transition: transform .2s ease;
}
.side-brand { display: flex; align-items: center; gap: 10px; padding: 18px 18px 14px; }
.side-brand .logo-mark { width: 34px; height: 34px; border-radius: 10px; box-shadow: none; }
.side-brand .name { color: #fff; font-weight: 700; font-size: 15px; line-height: 1.2; }
.side-brand .ver { color: #64748b; font-size: 11px; }
.side-nav { flex: 1; padding: 8px 12px; overflow-y: auto; }
.side-nav .group-label { font-size: 11px; color: #475569; padding: 14px 10px 6px; }
.nav-item {
  display: flex; align-items: center; gap: 10px; padding: 9px 10px; border-radius: 8px;
  color: #94a3b8; font-size: 13.5px; margin-bottom: 2px; user-select: none;
}
.nav-item:hover { background: var(--sidebar-hover); color: #e2e8f0; }
.nav-item.active { background: var(--primary); color: #fff; }
.nav-item svg { flex: none; }
.side-foot { padding: 14px 18px; border-top: 1px solid rgba(255, 255, 255, .08); display: flex; align-items: center; justify-content: space-between; }
.side-foot .who { color: #cbd5e1; font-size: 13px; }
.side-foot button { background: none; border: 0; color: #64748b; padding: 4px; border-radius: 6px; }
.side-foot button:hover { color: #f87171; background: var(--sidebar-hover); }

.main { margin-left: 224px; min-height: 100vh; display: flex; flex-direction: column; }
.topbar {
  background: var(--card); border-bottom: 1px solid var(--border); padding: 0 28px; height: 60px;
  display: flex; align-items: center; justify-content: space-between; position: sticky; top: 0; z-index: 30;
}
.topbar h2 { font-size: 17px; font-weight: 600; display: flex; align-items: center; gap: 10px; }
.topbar .actions { display: flex; gap: 10px; align-items: center; }
.content { padding: 24px 28px 48px; flex: 1; }
.foot { text-align: center; color: var(--text-3); font-size: 12px; padding: 0 0 20px; }

.menu-btn { display: none; background: none; border: 0; padding: 6px; color: var(--text-2); }
.scrim { display: none; position: fixed; inset: 0; background: rgba(15, 23, 42, .5); z-index: 39; }

/* ---------- 卡片 / 表格 ---------- */
.card { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); }
.card + .card { margin-top: 16px; }
.card-head { padding: 14px 18px; border-bottom: 1px solid var(--border); display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.card-head h3 { font-size: 14.5px; font-weight: 600; }
.card-body { padding: 18px; }
.table-wrap { overflow-x: auto; border-radius: 0 0 var(--radius) var(--radius); }
table { width: 100%; border-collapse: collapse; white-space: nowrap; }
th { text-align: left; font-size: 12px; font-weight: 500; color: var(--text-3); padding: 10px 14px; border-bottom: 1px solid var(--border); background: #f8fafc; }
td { padding: 11px 14px; border-bottom: 1px solid #f1f5f9; font-size: 13.5px; vertical-align: middle; }
tr:last-child td { border-bottom: 0; }
tbody tr:hover { background: #f8fafc; }
td.ops { text-align: right; }
td.num, th.num { text-align: right; }
.empty { padding: 48px 20px; text-align: center; color: var(--text-3); font-size: 13px; }
.empty svg { margin-bottom: 10px; opacity: .5; }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 12.5px; }
.sub { color: var(--text-3); font-size: 12px; }
.ellip { max-width: 260px; overflow: hidden; text-overflow: ellipsis; }

/* ---------- 徽章 / 按钮 / 表单 ---------- */
.badge { display: inline-flex; align-items: center; padding: 2px 9px; border-radius: 999px; font-size: 12px; font-weight: 500; }
.b-green { color: var(--green); background: var(--green-bg); }
.b-red { color: var(--red); background: var(--red-bg); }
.b-amber { color: var(--amber); background: var(--amber-bg); }
.b-blue { color: var(--blue); background: var(--blue-bg); }
.b-purple { color: var(--purple); background: var(--purple-bg); }
.b-gray { color: var(--gray); background: var(--gray-bg); }

.btn {
  display: inline-flex; align-items: center; gap: 6px; border-radius: 8px; border: 1px solid transparent;
  padding: 7px 14px; font-size: 13px; font-weight: 500; transition: all .15s;
}
.btn-pri { background: var(--primary); color: #fff; }
.btn-pri:hover { background: var(--primary-hover); }
.btn-sec { background: var(--card); color: var(--text-2); border-color: #cbd5e1; }
.btn-sec:hover { border-color: var(--text-3); color: var(--text); }
.btn-danger { background: var(--red); color: #fff; }
.btn-danger:hover { background: #b91c1c; }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn-sm { padding: 4px 10px; font-size: 12.5px; border-radius: 6px; }
.link-btn { background: none; border: 0; color: var(--primary); font-size: 12.5px; padding: 3px 6px; border-radius: 6px; }
.link-btn:hover { background: var(--blue-bg); }
.link-btn.danger { color: var(--red); }
.link-btn.danger:hover { background: var(--red-bg); }

.field { margin-bottom: 16px; }
.field label { display: block; font-size: 12.5px; font-weight: 500; color: var(--text-2); margin-bottom: 6px; }
.field .hint { font-size: 12px; color: var(--text-3); margin-top: 5px; }
.input, select.input, textarea.input {
  width: 100%; border: 1px solid #cbd5e1; border-radius: 8px; padding: 8px 12px; font-size: 13.5px;
  background: var(--card); outline: none; transition: border .15s, box-shadow .15s;
}
.input:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(79, 70, 229, .12); }
textarea.input { resize: vertical; min-height: 90px; }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.filters { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.filters .input { width: auto; }
.seg { display: inline-flex; border: 1px solid #cbd5e1; border-radius: 8px; overflow: hidden; }
.seg button { border: 0; background: var(--card); padding: 7px 16px; font-size: 13px; color: var(--text-2); }
.seg button + button { border-left: 1px solid #cbd5e1; }
.seg button.on { background: var(--primary); color: #fff; }
.switch { position: relative; width: 40px; height: 22px; flex: none; }
.switch input { opacity: 0; width: 0; height: 0; }
.switch i { position: absolute; inset: 0; background: #cbd5e1; border-radius: 999px; transition: .18s; }
.switch i::after { content: ''; position: absolute; width: 18px; height: 18px; border-radius: 50%; background: #fff; top: 2px; left: 2px; transition: .18s; box-shadow: 0 1px 3px rgba(0,0,0,.25); }
.switch input:checked + i { background: var(--primary); }
.switch input:checked + i::after { transform: translateX(18px); }

/* ---------- 仪表盘 ---------- */
.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 16px; margin-bottom: 16px; }
.stat {
  background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); padding: 18px;
  display: flex; align-items: center; gap: 14px;
}
.stat .ico { width: 42px; height: 42px; border-radius: 10px; display: flex; align-items: center; justify-content: center; flex: none; }
.stat .v { font-size: 22px; font-weight: 700; line-height: 1.15; }
.stat .k { font-size: 12.5px; color: var(--text-3); }
.grid2 { display: grid; grid-template-columns: 1.6fr 1fr; gap: 16px; align-items: start; }
.chart { display: flex; align-items: flex-end; gap: 12px; height: 170px; padding: 8px 6px 0; }
.chart .day { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 6px; height: 100%; justify-content: flex-end; }
.chart .bars { display: flex; gap: 4px; align-items: flex-end; height: 100%; }
.chart .bar { width: 14px; border-radius: 4px 4px 0 0; min-height: 2px; }
.chart .bar.in { background: #6366f1; }
.chart .bar.out { background: #a5b4fc; }
.chart .lbl { font-size: 11px; color: var(--text-3); }
.legend { display: flex; gap: 14px; font-size: 12px; color: var(--text-2); }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 5px; }
.kv { width: 100%; }
.kv td { padding: 8px 0; border: 0; font-size: 13px; }
.kv td:first-child { color: var(--text-3); width: 40%; }
.quota { display: flex; align-items: center; gap: 8px; }
.quota .track { width: 90px; height: 6px; border-radius: 999px; background: #e2e8f0; overflow: hidden; flex: none; }
.quota .fill { height: 100%; border-radius: 999px; background: var(--primary); }
.quota .fill.warn { background: var(--amber); }
.quota .fill.full { background: var(--red); }

/* ---------- 弹窗 / 提示 ---------- */
.modal-mask { position: fixed; inset: 0; background: rgba(15, 23, 42, .5); z-index: 60; display: flex; align-items: flex-start; justify-content: center; padding: 8vh 16px; overflow-y: auto; }
.modal { background: var(--card); border-radius: 14px; width: 480px; max-width: 100%; box-shadow: 0 24px 64px rgba(0, 0, 0, .3); animation: pop .16s ease; }
@keyframes pop { from { transform: translateY(8px); opacity: 0; } }
.modal-head { padding: 16px 20px; border-bottom: 1px solid var(--border); display: flex; justify-content: space-between; align-items: center; }
.modal-head h3 { font-size: 15px; font-weight: 600; }
.modal-head .x { background: none; border: 0; color: var(--text-3); padding: 4px; border-radius: 6px; line-height: 0; }
.modal-head .x:hover { background: var(--bg); color: var(--text); }
.modal-body { padding: 20px; }
.modal-foot { padding: 14px 20px; border-top: 1px solid var(--border); display: flex; justify-content: flex-end; gap: 10px; }
#toasts { position: fixed; top: 18px; right: 18px; z-index: 80; display: flex; flex-direction: column; gap: 8px; }
.toast {
  background: #0f172a; color: #f1f5f9; border-radius: 10px; padding: 10px 16px; font-size: 13px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, .25); animation: slide .2s ease; max-width: 360px;
}
.toast.err { background: #b91c1c; }
.toast.ok { background: #15803d; }
@keyframes slide { from { transform: translateX(16px); opacity: 0; } }

/* ---------- 读信 ---------- */
.msg-head { display: grid; gap: 6px; }
.msg-head .subj { font-size: 17px; font-weight: 600; }
.msg-head .line { font-size: 13px; color: var(--text-2); }
.msg-head .line b { color: var(--text); font-weight: 500; }
.mail-body { border: 1px solid var(--border); border-radius: 10px; margin-top: 14px; overflow: hidden; }
.mail-body pre { padding: 18px; white-space: pre-wrap; word-break: break-word; font: 13.5px/1.7 inherit; }
.mail-body iframe { width: 100%; height: 60vh; border: 0; background: #fff; }
.atts { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 12px; }
.att {
  display: inline-flex; align-items: center; gap: 7px; border: 1px solid var(--border); border-radius: 8px;
  padding: 7px 12px; font-size: 12.5px; color: var(--text-2); background: #f8fafc;
}
.tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--border); padding: 0 12px; background: #f8fafc; }
.tab { padding: 9px 14px; font-size: 13px; color: var(--text-3); border: 0; background: none; border-bottom: 2px solid transparent; }
.tab.on { color: var(--primary); border-color: var(--primary); font-weight: 500; }

/* ---------- 响应式 ---------- */
@media (max-width: 900px) {
  .sidebar { transform: translateX(-100%); }
  .sidebar.open { transform: none; box-shadow: 24px 0 48px rgba(0, 0, 0, .3); }
  .scrim.on { display: block; }
  .main { margin-left: 0; }
  .menu-btn { display: block; }
  .topbar { padding: 0 16px; }
  .content { padding: 16px 12px 40px; }
  .grid2, .row2 { grid-template-columns: 1fr; }
  .ellip { max-width: 150px; }
}
