:root {
  --brand: #5b5bd6;
  --brand-dark: #4646b8;
  --brand-soft: #eeedff;
  --bg: #f4f5fa;
  --surface: #ffffff;
  --surface-2: #f8f9fc;
  --line: #e4e6ef;
  --text: #1d2033;
  --text-2: #5a5f76;
  --text-3: #8b90a6;
  --green: #12805c;
  --green-soft: #e6f7f0;
  --red: #c5372e;
  --red-soft: #fdecea;
  --amber: #a86400;
  --amber-soft: #fff4e0;
  --blue-soft: #e9f1ff;
  --blue: #1d5dc7;
  --radius: 12px;
  --shadow: 0 6px 24px rgba(24, 28, 58, 0.06);
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--brand); text-decoration: none; }
h1, h2, h3, h4 { margin: 0; font-weight: 650; letter-spacing: -0.01em; }
p { margin: 0; }
button, input, select, textarea { font: inherit; color: inherit; }
.hidden { display: none !important; }

.container { max-width: 1080px; margin: 0 auto; padding: 0 24px; }

/* 顶部导航 */
.topbar {
  position: sticky; top: 0; z-index: 20;
  background: rgba(255, 255, 255, 0.9);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
}
.topbar-inner { display: flex; align-items: center; gap: 24px; height: 64px; }
.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 17px; }
.brand-mark {
  width: 32px; height: 32px; border-radius: 9px;
  background: #fff; color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-size: 15px; font-weight: 700;
  box-shadow: 0 4px 12px rgba(91, 91, 214, 0.28);
  overflow: hidden;
}
.brand-mark img { width: 100%; height: 100%; object-fit: cover; display: block; }
.nav { display: flex; gap: 4px; margin-left: auto; }
.nav a {
  padding: 8px 14px; border-radius: 8px; color: var(--text-2); font-weight: 500;
}
.nav a.active { background: var(--brand-soft); color: var(--brand); }
.nav a:hover { color: var(--brand); }
.quota-chip {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 7px 12px; border-radius: 999px;
  background: var(--brand-soft); color: var(--brand-dark);
  font-size: 13px; font-weight: 600; white-space: nowrap;
}
.quota-chip b { font-size: 15px; }

/* 通用 */
.card {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); box-shadow: var(--shadow);
}
.card-pad { padding: 22px; }
.section-title { display: flex; align-items: baseline; gap: 10px; margin-bottom: 14px; }
.section-title h2 { font-size: 17px; }
.section-title .sub { color: var(--text-3); font-size: 12.5px; }
.muted { color: var(--text-3); }
.text-2 { color: var(--text-2); }
.mt-8 { margin-top: 8px; }
.mt-12 { margin-top: 12px; }
.mt-16 { margin-top: 16px; }
.mt-24 { margin-top: 24px; }
.row { display: flex; align-items: center; gap: 12px; }
.between { justify-content: space-between; }
.wrap { flex-wrap: wrap; }
.grow { flex: 1; }
.right { margin-left: auto; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  border: 1px solid var(--line); background: var(--surface);
  color: var(--text); border-radius: 9px;
  padding: 9px 16px; font-size: 14px; font-weight: 550;
  cursor: pointer; transition: all .15s ease;
  white-space: nowrap;
}
.btn:hover { border-color: #cfd2e2; background: var(--surface-2); }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn-primary { background: var(--brand); border-color: var(--brand); color: #fff; box-shadow: 0 6px 16px rgba(91, 91, 214, 0.24); }
.btn-primary:hover { background: var(--brand-dark); border-color: var(--brand-dark); }
.btn-danger { color: var(--red); border-color: #f0cdc9; background: #fff8f7; }
.btn-danger:hover { background: var(--red-soft); }
.btn-sm { padding: 5px 10px; font-size: 12.5px; border-radius: 7px; }
.btn-lg { padding: 12px 24px; font-size: 15px; border-radius: 10px; }
.btn-block { width: 100%; }

.field { display: flex; flex-direction: column; gap: 7px; margin-bottom: 16px; }
.field > label { font-size: 13px; font-weight: 600; color: var(--text-2); }
.field .hint { font-size: 12px; color: var(--text-3); }
.input, .select, .textarea {
  width: 100%; padding: 10px 12px;
  border: 1px solid var(--line); border-radius: 9px;
  background: var(--surface); outline: none;
  transition: border-color .15s, box-shadow .15s;
  font-size: 14px;
}
.input:focus, .select:focus, .textarea:focus {
  border-color: var(--brand); box-shadow: 0 0 0 3px rgba(91, 91, 214, 0.12);
}
.textarea { resize: vertical; min-height: 120px; line-height: 1.6; }
.textarea.mono { font-family: "SFMono-Regular", Consolas, "Liberation Mono", monospace; font-size: 13px; }
.input-sm { padding: 7px 10px; font-size: 13px; }

.badge {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 3px 9px; border-radius: 999px; font-size: 12px; font-weight: 600;
  background: var(--surface-2); color: var(--text-2); white-space: nowrap;
}
.badge-green { background: var(--green-soft); color: var(--green); }
.badge-red { background: var(--red-soft); color: var(--red); }
.badge-amber { background: var(--amber-soft); color: var(--amber); }
.badge-blue { background: var(--blue-soft); color: var(--blue); }
.badge-brand { background: var(--brand-soft); color: var(--brand-dark); }

.alert {
  display: flex; gap: 10px; align-items: flex-start;
  padding: 12px 14px; border-radius: 10px; font-size: 13.5px;
  border: 1px solid transparent;
}
.alert-red { background: var(--red-soft); color: #8f2b23; border-color: #f5d0cc; }
.alert-amber { background: var(--amber-soft); color: #7a4c00; border-color: #f3dcb2; }
.alert-blue { background: var(--blue-soft); color: #1a4da7; border-color: #cddefb; }
.alert-green { background: var(--green-soft); color: #0c6046; border-color: #bfe9da; }

/* 表格 */
.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: 10px; }
table.data { width: 100%; border-collapse: collapse; font-size: 13px; min-width: 640px; }
table.data th {
  background: var(--surface-2); color: var(--text-2);
  text-align: left; padding: 10px 12px; font-weight: 600; font-size: 12.5px;
  border-bottom: 1px solid var(--line); white-space: nowrap;
}
table.data td { padding: 10px 12px; border-bottom: 1px solid #f0f1f7; vertical-align: top; }
table.data tr:last-child td { border-bottom: none; }
table.data tr:hover td { background: #fbfbfe; }
.cell-ellipsis { max-width: 220px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.actions { display: flex; gap: 6px; flex-wrap: wrap; }

.pagination { display: flex; align-items: center; gap: 8px; justify-content: flex-end; margin-top: 12px; font-size: 13px; color: var(--text-3); }

/* 用户页：激活 */
.hero { padding: 72px 0 48px; }
.hero-card { max-width: 520px; margin: 0 auto; padding: 36px; }
.hero h1 { font-size: 26px; margin-bottom: 8px; }
.hero .lead { color: var(--text-2); margin-bottom: 26px; }
.hero-badge {
  display: inline-flex; gap: 6px; align-items: center;
  background: var(--brand-soft); color: var(--brand-dark);
  padding: 5px 11px; border-radius: 999px; font-size: 12px; font-weight: 600; margin-bottom: 18px;
}
.activate-input {
  width: 100%; text-align: center; letter-spacing: 2px; font-weight: 600;
  font-size: 18px; padding: 14px; text-transform: uppercase;
}
.steps { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; margin-top: 28px; }
.step { padding: 18px; border-radius: 12px; background: var(--surface); border: 1px solid var(--line); }
.step-num { width: 24px; height: 24px; border-radius: 7px; background: var(--brand-soft); color: var(--brand-dark); display: flex; align-items: center; justify-content: center; font-size: 12px; font-weight: 700; margin-bottom: 10px; }
.step h4 { font-size: 14px; margin-bottom: 4px; }
.step p { font-size: 12.5px; color: var(--text-3); }

/* 用户页：发信 */
.page { padding: 28px 0 64px; }
.panel { padding: 24px; }
.panel + .panel { margin-top: 18px; }

.mailbox-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 12px; }
.mailbox-option {
  display: flex; flex-direction: column; gap: 8px;
  border: 1.5px solid var(--line); border-radius: 11px;
  padding: 14px 16px; cursor: pointer; background: var(--surface);
  transition: border-color .15s, box-shadow .15s, background .15s;
  position: relative;
}
.mailbox-option:hover { border-color: #c9cbf0; }
.mailbox-option.selected { border-color: var(--brand); background: #f7f7ff; box-shadow: 0 0 0 3px rgba(91,91,214,.1); }
.mailbox-option.disabled { opacity: .55; cursor: not-allowed; }
.mailbox-email { font-weight: 650; font-size: 14.5px; word-break: break-all; }
.mailbox-meta { display: flex; gap: 8px; flex-wrap: wrap; font-size: 12px; color: var(--text-3); }
.mailbox-card-list { max-height: 430px; overflow-y: auto; padding-right: 4px; }

.compose-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.estimate {
  display: flex; justify-content: space-between; align-items: center;
  padding: 14px 16px; border-radius: 10px; background: var(--surface-2); border: 1px dashed #d9dcec;
  font-size: 13px; color: var(--text-2);
}
.estimate b { color: var(--brand-dark); font-size: 18px; }
.file-list { display: flex; flex-direction: column; gap: 6px; margin-top: 8px; }
.file-item { display: flex; justify-content: space-between; gap: 12px; font-size: 12.5px; color: var(--text-2); background: var(--surface-2); padding: 6px 10px; border-radius: 7px; }

.segmented { display: inline-flex; background: var(--surface-2); border-radius: 9px; padding: 3px; border: 1px solid var(--line); }
.segmented button { border: none; background: transparent; padding: 7px 14px; border-radius: 7px; font-size: 13px; cursor: pointer; color: var(--text-2); font-weight: 500; }
.segmented button.active { background: var(--surface); color: var(--brand-dark); box-shadow: 0 1px 4px rgba(0,0,0,.06); font-weight: 600; }

.progress-bar { height: 6px; border-radius: 999px; background: #e7e8f2; overflow: hidden; }
.progress-bar > i { display: block; height: 100%; background: var(--brand); width: 0; transition: width .3s ease; }

/* 用户页：收信 */
.search-row { display: flex; gap: 10px; }
.recipient-chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  border: 1px solid var(--line); background: var(--surface); border-radius: 999px;
  padding: 5px 12px; font-size: 12.5px; cursor: pointer; color: var(--text-2);
}
.chip:hover { border-color: var(--brand); color: var(--brand); }
.send-card { border: 1px solid var(--line); border-radius: 11px; padding: 16px; background: var(--surface); }
.send-card + .send-card { margin-top: 12px; }
.send-head { display: flex; gap: 10px; align-items: flex-start; justify-content: space-between; flex-wrap: wrap; }
.send-subject { font-weight: 650; font-size: 14.5px; }
.send-meta { color: var(--text-3); font-size: 12px; margin-top: 3px; }
.reply-list { margin-top: 12px; border-left: 3px solid var(--brand-soft); padding-left: 12px; display: flex; flex-direction: column; gap: 10px; }
.reply { background: var(--surface-2); border: 1px solid var(--line); border-radius: 9px; padding: 12px; }
.reply-head { display: flex; justify-content: space-between; gap: 8px; font-size: 12px; color: var(--text-3); flex-wrap: wrap; }
.reply-body { margin-top: 8px; font-size: 13px; color: var(--text-2); white-space: pre-wrap; word-break: break-word; max-height: 220px; overflow: auto; }
.reply-body-html { margin-top: 8px; width: 100%; border: 1px solid var(--line); border-radius: 8px; background: #fff; }
.attachment-row { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 8px; }
.attachment-link { display: inline-flex; gap: 6px; align-items: center; font-size: 12px; padding: 4px 10px; border-radius: 7px; background: var(--surface); border: 1px solid var(--line); color: var(--text-2); }
.attachment-link:hover { border-color: var(--brand); color: var(--brand); }

.toast {
  position: fixed; left: 50%; bottom: 32px; transform: translateX(-50%);
  background: #23263a; color: #fff; padding: 11px 18px; border-radius: 10px;
  font-size: 13.5px; z-index: 100; box-shadow: 0 10px 30px rgba(0,0,0,.2);
  opacity: 0; pointer-events: none; transition: opacity .2s, transform .2s;
  max-width: min(560px, calc(100vw - 32px));
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(-6px); }
.toast.error { background: #8f2b23; }

/* 管理后台 */
.admin-body { background: #f1f2f7; }
.admin-shell { display: grid; grid-template-columns: 232px 1fr; min-height: 100vh; }
.sidebar {
  background: #1f2233; color: #c9cce0; padding: 22px 14px;
  position: sticky; top: 0; height: 100vh; overflow-y: auto;
}
.sidebar .brand { color: #fff; margin-bottom: 24px; padding: 0 8px; font-size: 15px; gap: 8px; }
.sidebar .brand-mark {
  width: 26px; height: 26px; flex: 0 0 26px; border-radius: 7px; box-shadow: none;
}
.sidebar .brand-mark img { object-fit: contain; }
.sidebar-nav { display: flex; flex-direction: column; gap: 3px; }
.sidebar-nav button, .sidebar-nav a {
  display: flex; align-items: center; gap: 10px;
  width: 100%; border: none; background: transparent; color: #b6bad2;
  text-align: left; padding: 10px 12px; border-radius: 8px; cursor: pointer; font-size: 13.5px;
  text-decoration: none;
}
.sidebar-nav button:hover, .sidebar-nav a:hover { background: rgba(255,255,255,.06); color: #fff; }
.sidebar-nav button.active, .sidebar-nav a.active { background: var(--brand); color: #fff; font-weight: 600; }
.sidebar-foot { margin-top: 24px; padding: 12px 8px; font-size: 12px; color: #7c8099; border-top: 1px solid rgba(255,255,255,.08); }
.admin-main { padding: 22px 26px 40px; min-width: 0; }
.admin-head { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 18px; }
.admin-head h1 { font-size: 20px; }
.admin-head .sub { color: var(--text-3); font-size: 12.5px; }

.stat-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 12px; margin-bottom: 18px; }
.stat {
  background: var(--surface); border: 1px solid var(--line); border-radius: 11px; padding: 16px 18px;
}
.stat .label { font-size: 12.5px; color: var(--text-3); }
.stat .value { font-size: 24px; font-weight: 700; margin-top: 6px; letter-spacing: -0.02em; }
.stat .value small { font-size: 12px; color: var(--text-3); font-weight: 500; margin-left: 4px; }

.toolbar { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 14px; }
.toolbar .input, .toolbar .select { width: auto; min-width: 160px; }

.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0 16px; }
.form-grid .full { grid-column: 1 / -1; }
.modal-mask {
  position: fixed; inset: 0; background: rgba(20, 22, 38, .45);
  display: flex; align-items: center; justify-content: center; z-index: 60; padding: 24px;
}
.modal {
  background: var(--surface); border-radius: 14px; width: 100%; max-width: 640px;
  max-height: calc(100vh - 48px); display: flex; flex-direction: column;
  box-shadow: 0 24px 80px rgba(0,0,0,.28);
}
.modal-head { padding: 18px 22px; border-bottom: 1px solid var(--line); display: flex; align-items: center; justify-content: space-between; }
.modal-head h3 { font-size: 16px; }
.modal-body { padding: 20px 22px; overflow-y: auto; }
.modal-foot { padding: 14px 22px; border-top: 1px solid var(--line); display: flex; justify-content: flex-end; gap: 10px; background: var(--surface-2); border-radius: 0 0 14px 14px; }
.close-btn { border: none; background: transparent; font-size: 20px; cursor: pointer; color: var(--text-3); line-height: 1; padding: 2px 6px; border-radius: 6px; }
.close-btn:hover { background: var(--surface-2); color: var(--text); }

.meta-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 14px 22px; }
.meta-item { border-bottom: 1px dashed var(--line); padding-bottom: 10px; }
.meta-label { font-size: 12px; color: var(--text-3); margin-bottom: 2px; }
.meta-value { font-size: 13.5px; color: var(--text); word-break: break-all; }
.body-preview {
  margin: 0; padding: 16px; background: var(--surface-2); border: 1px solid var(--line);
  border-radius: 8px; white-space: pre-wrap; word-break: break-word; font-family: inherit; font-size: 13.5px;
}

.login-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 24px; background: radial-gradient(900px 500px at 20% 10%, #e9e8ff, transparent), #f4f5fa; }
.login-card { width: 100%; max-width: 400px; padding: 34px; }
.login-card h1 { font-size: 22px; margin-bottom: 6px; }
.login-card .lead { color: var(--text-3); font-size: 13px; margin-bottom: 24px; }

.overview-split { display: grid; grid-template-columns: 1.15fr .85fr; gap: 16px; }
@media (max-width: 1000px) {
  .overview-split { grid-template-columns: 1fr; }
  .admin-shell { grid-template-columns: 1fr; }
  .sidebar { position: static; height: auto; padding: 14px; }
  .sidebar-nav { flex-direction: row; flex-wrap: wrap; }
  .sidebar .brand, .sidebar-foot { display: none; }
}
@media (max-width: 820px) {
  .compose-grid { grid-template-columns: 1fr; }
  .steps { grid-template-columns: 1fr; }
  .nav a { padding: 8px 10px; }
  .topbar-inner { gap: 12px; }
  .quota-chip { display: none; }
  .hero { padding: 40px 0 28px; }
  .hero-card { padding: 26px; }
  .form-grid { grid-template-columns: 1fr; }
  .admin-main { padding: 16px; }
  .cell-ellipsis { max-width: 140px; }
}
