/* 邮件系统管理后台
   视觉主题：航空信封。顶部红蓝斜纹是唯一的装饰元素，其余保持克制。 */
:root {
  --paper: #f3f5f4;      /* 页面底色：偏冷的纸色 */
  --panel: #ffffff;
  --ink: #17212b;        /* 正文 */
  --ink-2: #4a5763;      /* 次要文字 */
  --muted: #7a8691;
  --line: #dde3e1;
  --line-soft: #eceff0;
  --blue: #1f4ba5;       /* 航空信蓝：主色 */
  --blue-ink: #183c86;
  --blue-soft: #eaf0fb;
  --red: #c8323c;        /* 航空信红：危险 / 失败 */
  --red-soft: #fcefef;
  --ok: #1e7f55; --ok-soft: #e8f5ee;
  --warn: #a8620a; --warn-soft: #fdf3e2;
  --sidebar: 224px;
  --r-lg: 12px; --r: 8px; --r-sm: 6px;
  --shadow-pop: 0 18px 48px -12px rgba(23, 33, 43, .28), 0 2px 6px rgba(23, 33, 43, .08);
  --stripe: repeating-linear-gradient(-45deg, var(--red) 0 10px, #fff 10px 16px, var(--blue) 16px 26px, #fff 26px 32px);
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "Segoe UI", sans-serif;
  font-size: 14px; line-height: 1.55; color: var(--ink);
  -webkit-font-smoothing: antialiased;
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--paper); }
a { color: var(--blue); text-decoration: none; }
a:hover { text-decoration: underline; }
button { font: inherit; cursor: pointer; color: inherit; }
input, select, textarea { font: inherit; color: inherit; }
code, pre, .mono { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 12.5px; }
.num { font-variant-numeric: tabular-nums; }
:focus-visible { outline: 2px solid var(--blue); outline-offset: 2px; }
.ico { display: inline-flex; width: 16px; height: 16px; flex: none; }
.ico svg { width: 100%; height: 100%; }

/* ---------- 布局 ---------- */
.airmail { height: 6px; background: var(--stripe); position: fixed; inset: 0 0 auto 0; z-index: 5; }
.layout { display: flex; min-height: 100vh; padding-top: 6px; }
.sidebar { width: var(--sidebar); background: var(--panel); border-right: 1px solid var(--line); display: flex; flex-direction: column;
  position: fixed; top: 6px; bottom: 0; left: 0; }
.brand { display: flex; align-items: center; gap: 10px; padding: 20px 18px 18px; }
.brand-mark { width: 34px; height: 34px; border-radius: var(--r); background: var(--blue); color: #fff; display: grid; place-items: center; flex: none; }
.brand-mark .ico { width: 20px; height: 20px; }
.brand-text { min-width: 0; }
.brand-text b { display: block; font-size: 15px; font-weight: 600; }
.brand-text small { display: block; color: var(--muted); font-size: 12px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.nav { padding: 4px 10px; display: flex; flex-direction: column; gap: 2px; }
.nav-group { color: var(--muted); font-size: 12px; padding: 14px 10px 6px; }
.nav a { display: flex; align-items: center; gap: 10px; padding: 8px 10px; color: var(--ink-2); border-radius: var(--r-sm); }
.nav a:hover { background: var(--paper); color: var(--ink); text-decoration: none; }
.nav a.active { background: var(--blue-soft); color: var(--blue-ink); font-weight: 600; }
.nav a .ico { color: var(--muted); }
.nav a.active .ico { color: var(--blue); }
.sidebar .foot { margin-top: auto; padding: 14px 18px; border-top: 1px solid var(--line-soft); display: flex; align-items: center; gap: 10px; }
.avatar { width: 28px; height: 28px; border-radius: 50%; background: var(--paper); border: 1px solid var(--line); display: grid; place-items: center; font-size: 12px; font-weight: 600; color: var(--ink-2); text-transform: uppercase; }
.foot .who { flex: 1; min-width: 0; font-size: 13px; }
.foot .logout { border: 1px solid var(--line); background: var(--panel); border-radius: var(--r-sm); padding: 3px 10px; font-size: 12.5px; color: var(--ink-2); }
.foot .logout:hover { color: var(--red); border-color: #e9c3c6; }

.main { margin-left: var(--sidebar); flex: 1; padding: 28px 32px 48px; min-width: 0; max-width: calc(var(--sidebar) + 1280px); }
.page-head { display: flex; align-items: flex-start; justify-content: space-between; margin-bottom: 20px; gap: 16px; flex-wrap: wrap; }
.page-head h1 { font-size: 22px; margin: 0; font-weight: 600; letter-spacing: .01em; }
.page-head .sub { margin: 4px 0 0; color: var(--ink-2); font-size: 13.5px; max-width: 72ch; }

/* ---------- 基础组件 ---------- */
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--r-lg); }
.card-body { padding: 18px 20px; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 14px 20px; border-bottom: 1px solid var(--line-soft); flex-wrap: wrap; }
.card-head h2 { font-size: 15px; margin: 0; font-weight: 600; }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; border: 1px solid var(--line); background: var(--panel);
  padding: 6px 14px; border-radius: var(--r-sm); color: var(--ink); white-space: nowrap; line-height: 1.5; vertical-align: middle; font-weight: 400; }
.btn:hover { border-color: #c4ccca; background: #fafbfb; text-decoration: none; }
.btn-primary { background: var(--blue); border-color: var(--blue); color: #fff; }
.btn-primary:hover { background: var(--blue-ink); border-color: var(--blue-ink); }
.btn-danger { color: var(--red); }
.btn-danger:hover { border-color: #e9c3c6; background: var(--red-soft); }
.btn-ghost { border-color: transparent; background: transparent; color: var(--ink-2); }
.btn-ghost:hover { background: var(--paper); border-color: transparent; color: var(--ink); }
.btn-sm { padding: 3px 10px; font-size: 13px; }
.btn-icon { padding: 4px; width: 28px; height: 28px; }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn .ico { width: 15px; height: 15px; }

.input { border: 1px solid var(--line); border-radius: var(--r-sm); padding: 7px 10px; background: var(--panel); min-width: 0; height: 34px; }
.input:hover { border-color: #c4ccca; }
.input:focus { outline: none; border-color: var(--blue); box-shadow: 0 0 0 3px var(--blue-soft); }
select.input { padding-right: 28px; }
.search { position: relative; display: inline-flex; }
.search .ico { position: absolute; left: 10px; top: 9px; color: var(--muted); pointer-events: none; }
.search .input { padding-left: 32px; width: 240px; }
.toolbar { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.toolbar .spacer { flex: 1; }
.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 16px; }
.field > label { color: var(--ink); font-size: 13px; font-weight: 500; }
.check { display: inline-flex; align-items: center; gap: 8px; margin-right: 18px; }
.hint { color: var(--muted); font-size: 12.5px; }
.error { color: var(--red); margin: 8px 0; }
.alert { display: flex; gap: 10px; align-items: flex-start; padding: 10px 14px; border-radius: var(--r); background: var(--red-soft); color: var(--red); margin-bottom: 16px; }
.alert.info { background: var(--blue-soft); color: var(--blue-ink); }
.alert .ico { margin-top: 2px; }
.alert-body { color: var(--ink-2); }

/* 开关（替代权限复选框） */
.switch { appearance: none; -webkit-appearance: none; width: 34px; height: 20px; border-radius: 10px; background: #cfd6d4; position: relative; cursor: pointer; margin: 0; transition: background .15s; vertical-align: middle; flex: none; }
.switch::after { content: ""; position: absolute; top: 2px; left: 2px; width: 16px; height: 16px; border-radius: 50%; background: #fff; box-shadow: 0 1px 2px rgba(0,0,0,.2); transition: transform .15s; }
.switch:checked { background: var(--blue); }
.switch:checked::after { transform: translateX(14px); }
.switch:disabled { opacity: .5; cursor: not-allowed; }

/* ---------- 表格 ---------- */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 11px 16px; border-bottom: 1px solid var(--line-soft); vertical-align: middle; }
th { color: var(--muted); font-weight: 500; font-size: 12.5px; white-space: nowrap; background: #fafbfb; border-bottom-color: var(--line); }
thead tr:first-child th:first-child { border-top-left-radius: var(--r-lg); }
thead tr:first-child th:last-child { border-top-right-radius: var(--r-lg); }
.card-head + .table-wrap th { border-radius: 0 !important; }
tbody tr:last-child td { border-bottom: 0; }
tr.clickable { cursor: pointer; }
tr.clickable:hover td { background: #f7f9fc; }
tr.clickable:focus-visible { outline: 2px solid var(--blue); outline-offset: -2px; }
tr.muted td { color: var(--muted); }
td.ellipsis { max-width: 300px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
td.nowrap, th.nowrap { white-space: nowrap; }
td.actions { white-space: nowrap; text-align: right; }
td.actions .btn + .btn { margin-left: 6px; }
.subject { font-weight: 500; }
.cell-sub { display: block; color: var(--muted); font-size: 12px; }

.badge { display: inline-flex; align-items: center; gap: 6px; padding: 2px 9px 2px 8px; border-radius: 999px; font-size: 12px; background: var(--line-soft); color: var(--ink-2); white-space: nowrap; line-height: 1.6; }
.badge::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; opacity: .85; }
.badge.plain::before { display: none; }
.badge.ok { background: var(--ok-soft); color: var(--ok); }
.badge.warn { background: var(--warn-soft); color: var(--warn); }
.badge.bad { background: var(--red-soft); color: var(--red); }
.badge.info { background: var(--blue-soft); color: var(--blue); }
.badge.info::before { animation: pulse 1.6s ease-in-out infinite; }
@keyframes pulse { 50% { opacity: .25; } }

.pager { display: flex; justify-content: space-between; align-items: center; padding: 10px 16px; color: var(--muted); border-top: 1px solid var(--line-soft); font-size: 13px; gap: 12px; flex-wrap: wrap; }

/* 空状态 */
.empty { text-align: center; color: var(--muted); padding: 48px 16px; }
.empty-ico { width: 44px; height: 44px; margin: 0 auto 12px; border-radius: 50%; background: var(--paper); color: var(--muted); display: grid; place-items: center; }
.empty-ico .ico { width: 22px; height: 22px; }
.empty b { display: block; color: var(--ink); font-weight: 600; font-size: 14.5px; margin-bottom: 4px; }
.empty p { margin: 0 auto; max-width: 40ch; font-size: 13px; }
.empty .btn { margin-top: 14px; }
td.empty-cell { padding: 0; border: 0; }
.loading { display: inline-flex; align-items: center; gap: 8px; }
.spinner { width: 16px; height: 16px; border: 2px solid var(--line); border-top-color: var(--blue); border-radius: 50%; animation: spin .7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- 概览 ---------- */
.stats { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 0; margin-bottom: 20px; }
.stat { padding: 18px 20px; border-right: 1px solid var(--line-soft); border-bottom: 1px solid var(--line-soft); }
.stat:nth-child(3n) { border-right: 0; }
.stat:nth-last-child(-n+3) { border-bottom: 0; }
.stat .label { color: var(--ink-2); font-size: 13px; display: flex; align-items: center; gap: 8px; }
.stat .label .ico { color: var(--muted); }
.stat .value { font-size: 30px; font-weight: 600; margin-top: 6px; line-height: 1.2; font-variant-numeric: tabular-nums; letter-spacing: -.01em; }
.stat .value small { font-size: 15px; color: var(--muted); font-weight: 500; margin: 0 4px; }
.stat .foot-note { color: var(--muted); font-size: 12px; margin-top: 2px; }
.stat.bad .value { color: var(--red); }
.stat.bad .label .ico { color: var(--red); }

.chart-wrap { display: grid; grid-template-columns: 36px 1fr; gap: 8px; padding: 16px 20px 14px; }
.y-axis { position: relative; height: 200px; font-size: 11px; color: var(--muted); font-variant-numeric: tabular-nums; }
.y-axis span { position: absolute; right: 0; transform: translateY(-50%); line-height: 1; }
.y-axis span:nth-child(1) { top: 0; } .y-axis span:nth-child(2) { top: 50%; } .y-axis span:nth-child(3) { top: 100%; }
.chart { position: relative; display: flex; align-items: flex-end; gap: 6px; height: 200px;
  background: linear-gradient(var(--line-soft) 1px, transparent 1px) 0 0 / 100% 50%; border-bottom: 1px solid var(--line); }
.chart .col { flex: 1; position: relative; height: 100%; display: flex; align-items: flex-end; justify-content: center; gap: 3px; border-radius: 4px 4px 0 0; }
.chart .col:hover { background: rgba(31, 75, 165, .05); }
.chart .bar { width: 38%; max-width: 16px; border-radius: 3px 3px 0 0; min-height: 2px; }
.chart .bar.sent { background: var(--blue); }
.chart .bar.recv { background: #9fb1d6; }
.chart .tip { display: none; position: absolute; bottom: calc(var(--h, 0%) + 8px); left: 50%; transform: translateX(-50%); background: var(--ink); color: #fff; font-size: 12px; padding: 6px 10px; border-radius: var(--r-sm); white-space: nowrap; z-index: 2; pointer-events: none; }
.chart .col:hover .tip { display: block; }
.x-axis { display: flex; gap: 6px; grid-column: 2; font-size: 11px; color: var(--muted); }
.x-axis span { flex: 1; text-align: center; white-space: nowrap; }
.x-axis span.today { color: var(--ink); font-weight: 600; }
.legend { display: flex; gap: 16px; font-size: 12.5px; color: var(--ink-2); align-items: center; }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 2px; margin-right: 6px; vertical-align: -1px; }
.legend b { font-variant-numeric: tabular-nums; margin-left: 4px; }

/* ---------- 弹窗 / 抽屉 ---------- */
.mask { position: fixed; inset: 0; background: rgba(23, 33, 43, .42); z-index: 10; display: flex; justify-content: center; align-items: flex-start; padding: 72px 16px; overflow: auto; animation: fade .15s ease-out; }
@keyframes fade { from { opacity: 0; } }
.modal { width: 100%; max-width: 520px; box-shadow: var(--shadow-pop); border: 0; animation: rise .18s ease-out; }
.modal.wide { max-width: 760px; }
@keyframes rise { from { transform: translateY(8px); opacity: 0; } }
.modal-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 16px 20px; border-bottom: 1px solid var(--line-soft); font-weight: 600; font-size: 15px; }
.modal .card-body { padding: 20px; }
.modal-foot { display: flex; justify-content: flex-end; gap: 8px; padding: 14px 20px; border-top: 1px solid var(--line-soft); background: #fafbfb; border-radius: 0 0 var(--r-lg) var(--r-lg); }
.close { border: 0; background: none; color: var(--muted); width: 30px; height: 30px; border-radius: var(--r-sm); display: grid; place-items: center; }
.close:hover { background: var(--paper); color: var(--ink); }
.drawer-mask { justify-content: flex-end; padding: 0; }
.drawer { width: min(880px, 100%); height: 100vh; overflow: auto; border-radius: 0; border: 0; box-shadow: var(--shadow-pop); animation: slide .2s ease-out; }
@keyframes slide { from { transform: translateX(24px); opacity: .6; } }
.drawer .modal-head { position: sticky; top: 0; background: var(--panel); z-index: 1; }
.drawer .modal-head .ico { color: var(--muted); }
.drawer-title { font-size: 19px; margin: 0 0 6px; font-weight: 600; line-height: 1.4; }
.drawer-meta { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 18px; }

.kv { display: grid; grid-template-columns: 88px 1fr; gap: 8px 16px; margin: 0; padding: 14px 16px; background: #fafbfb; border: 1px solid var(--line-soft); border-radius: var(--r); }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; word-break: break-all; }
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin: 20px 0 14px; overflow-x: auto; }
.tabs button { border: 0; background: none; padding: 9px 12px; color: var(--ink-2); border-bottom: 2px solid transparent; margin-bottom: -1px; white-space: nowrap; }
.tabs button:hover { color: var(--ink); }
.tabs button.active { color: var(--blue); border-bottom-color: var(--blue); font-weight: 600; }
.mail-frame { width: 100%; height: 520px; border: 1px solid var(--line); border-radius: var(--r); background: #fff; }
pre.box { background: #f7f9f9; border: 1px solid var(--line-soft); border-radius: var(--r); padding: 14px; white-space: pre-wrap; word-break: break-all; margin: 0; max-height: 520px; overflow: auto; line-height: 1.6; }
.code-box { position: relative; }
.code-box .btn { position: absolute; top: 8px; right: 8px; }
.secret { background: var(--warn-soft); border: 1px solid #f0d7a8; border-radius: var(--r); padding: 12px 14px; margin-bottom: 16px; color: var(--warn); }
.secret code { font-size: 14px; word-break: break-all; color: var(--ink); background: #fff; border: 1px solid #f0d7a8; border-radius: var(--r-sm); padding: 6px 10px; flex: 1; }
.copy-row { display: flex; gap: 8px; align-items: center; }
.domain-input { display: flex; align-items: center; border: 1px solid var(--line); border-radius: var(--r-sm); overflow: hidden; }
.domain-input:focus-within { border-color: var(--blue); box-shadow: 0 0 0 3px var(--blue-soft); }
.domain-input .input { border: 0; box-shadow: none !important; border-radius: 0; }
.domain-input .at { padding: 0 8px; color: var(--muted); background: #fafbfb; align-self: stretch; display: grid; place-items: center; border-left: 1px solid var(--line-soft); border-right: 1px solid var(--line-soft); }

/* 域名 DNS */
.domain-card { margin-bottom: 20px; }
.domain-card .card-head h2 { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.dns-val { display: flex; align-items: flex-start; gap: 6px; }
.dns-val .mono { word-break: break-all; flex: 1; min-width: 0; }
.found { margin-top: 4px; color: var(--red); font-size: 12px; word-break: break-all; }
.type-tag { display: inline-block; min-width: 40px; text-align: center; padding: 1px 6px; border: 1px solid var(--line); border-radius: var(--r-sm); font-size: 12px; font-weight: 600; color: var(--ink-2); font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; }

/* ---------- 登录 ---------- */
.login { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 24px; }
.login .card { width: 380px; max-width: 100%; overflow: hidden; box-shadow: 0 24px 60px -24px rgba(23, 33, 43, .25); }
.login .stripe { height: 8px; background: var(--stripe); }
.login form { padding: 30px 30px 26px; }
.login .brand { padding: 0 0 22px; }
.login .btn { width: 100%; padding: 9px; margin-top: 6px; }
.login .input { width: 100%; height: 38px; }

.toast { position: fixed; top: 22px; left: 50%; transform: translateX(-50%); background: var(--ink); color: #fff; padding: 9px 16px; border-radius: var(--r); z-index: 30; box-shadow: var(--shadow-pop); display: flex; align-items: center; gap: 8px; animation: rise .18s ease-out; }

@media (max-width: 1080px) {
  .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .stat:nth-child(3n) { border-right: 1px solid var(--line-soft); }
  .stat:nth-child(2n) { border-right: 0; }
  .stat:nth-last-child(-n+3) { border-bottom: 1px solid var(--line-soft); }
  .stat:nth-last-child(-n+2) { border-bottom: 0; }
}
@media (max-width: 760px) {
  .layout { flex-direction: column; }
  .sidebar { position: sticky; top: 6px; width: 100%; z-index: 4; border-right: 0; border-bottom: 1px solid var(--line); }
  .brand { padding: 12px 16px 6px; }
  .brand-mark { width: 28px; height: 28px; }
  .nav { flex-direction: row; overflow-x: auto; padding: 4px 10px 8px; scrollbar-width: none; }
  .nav-group { display: none; }
  .nav a { white-space: nowrap; padding: 6px 10px; }
  .sidebar .foot { position: absolute; top: 12px; right: 12px; border: 0; padding: 0; }
  .sidebar .foot .who, .sidebar .foot .avatar { display: none; }
  .main { margin-left: 0; padding: 18px 14px 40px; }
  .page-head { align-items: stretch; flex-direction: column; }
  .page-head > .btn { align-self: flex-start; }
  .page-head h1 { font-size: 20px; }
  .search, .search .input { width: 100%; }
  .toolbar > * { flex: 1 1 auto; }
  .chart-wrap { padding: 12px; grid-template-columns: 28px 1fr; }
  .chart, .x-axis { gap: 2px; }
  .x-axis span:nth-child(odd) { visibility: hidden; }
  .x-axis span.today { visibility: visible; }
  .stat .value { font-size: 24px; }
  .hide-sm { display: none; }
  td.ellipsis { max-width: 180px; }
  .kv { grid-template-columns: 72px 1fr; }
  .mask { padding: 24px 10px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}

/* ---------- 平台设置 ---------- */
.settings-form { max-width: 860px; }
.setting-row { display: flex; justify-content: space-between; align-items: flex-start; gap: 24px; padding: 16px 20px; border-bottom: 1px solid var(--line-soft); }
.setting-row:last-child { border-bottom: 0; }
.setting-row > div { flex: 1; min-width: 0; }
.setting-row b { font-weight: 600; font-size: 14px; }
.setting-row p { margin: 3px 0 0; color: var(--ink-2); font-size: 13px; max-width: 62ch; }
.setting-row > .switch { margin-top: 2px; }
.setting-row.off { opacity: .55; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; align-items: center; }
.chips .check { margin-right: 10px; }
.chip { display: inline-flex; align-items: center; gap: 6px; border: 1px solid var(--line); border-radius: 999px; padding: 3px 12px 3px 8px; cursor: pointer; font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 12.5px; background: var(--panel); }
.chip.on { border-color: var(--blue); background: var(--blue-soft); color: var(--blue-ink); }
.chip input { margin: 0; accent-color: var(--blue); }
.unit-input { display: inline-flex; align-items: center; gap: 8px; color: var(--ink-2); }
.unit-input .input { width: 110px; text-align: right; }
.save-bar { position: sticky; bottom: 0; display: flex; justify-content: flex-end; align-items: center; gap: 14px; margin-top: 20px; padding: 12px 0; background: linear-gradient(transparent, var(--paper) 30%); }
@media (max-width: 760px) {
  .setting-row { flex-direction: column; gap: 10px; }
}
