:root {
  --brand: #3b6ef5;
  --brand-dark: #2f5ce0;
  --bg: #f4f6fa;
  --card: #ffffff;
  --line: #e6e9f0;
  --text: #1f2937;
  --muted: #7a8599;
  --ok: #0ea472;
  --warn: #d98317;
  --danger: #e0463f;
  --side: #101827;
  --side-2: #16202f;
  --radius: 12px;
}
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font: 14px/1.6 -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
        "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}
a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; }
.mono { font-family: "SFMono-Regular", Consolas, "Liberation Mono", Menlo, monospace; }
.dim { color: var(--muted); }
.small { font-size: 12px; }
.hidden { display: none; }

/* ---------------- 布局 ---------------- */
.app { display: flex; min-height: 100vh; }
.sidebar {
  width: 232px; flex: 0 0 232px; background: var(--side); color: #cbd5e1;
  display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh;
}
.brand { display: flex; align-items: center; gap: 10px; padding: 20px 18px 18px; }
.brand-mark {
  width: 34px; height: 34px; border-radius: 9px; flex: 0 0 34px;
  background: linear-gradient(135deg, #3b6ef5, #6f9bff); color: #fff;
  display: grid; place-items: center; font-weight: 700; font-size: 17px;
}
.brand b { display: block; color: #fff; font-size: 14px; letter-spacing: .3px; }
.brand small { color: #7d8ba3; font-size: 11px; }

nav { padding: 6px 10px; flex: 1; }
.nav-item {
  display: flex; align-items: center; gap: 10px; padding: 10px 12px; margin-bottom: 2px;
  border-radius: 9px; color: #b6c2d4; font-size: 13.5px; text-decoration: none;
}
.nav-item svg { width: 17px; height: 17px; flex: 0 0 17px; }
.nav-item:hover { background: var(--side-2); color: #fff; text-decoration: none; }
.nav-item.active { background: linear-gradient(90deg, rgba(59,110,245,.22), rgba(59,110,245,.08));
  color: #fff; box-shadow: inset 2px 0 0 var(--brand); }
.nav-badge {
  margin-left: auto; background: var(--danger); color: #fff; font-size: 11px;
  font-weight: 600; border-radius: 9px; padding: 1px 7px;
}
.side-foot { padding: 14px; border-top: 1px solid #1e2a3d; }
.side-stat { display: flex; justify-content: space-between; font-size: 12px; color: #7d8ba3; padding: 3px 0; }
.side-stat b { color: #e2e8f0; }
.logout {
  display: block; margin-top: 10px; text-align: center; padding: 8px; border-radius: 8px;
  background: #1b2637; color: #9fb0c7; font-size: 12.5px; text-decoration: none;
}
.logout:hover { background: #24334a; color: #fff; text-decoration: none; }

.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar {
  height: 58px; background: #fff; border-bottom: 1px solid var(--line);
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 24px; position: sticky; top: 0; z-index: 20;
}
.topbar h1 { font-size: 15.5px; font-weight: 600; margin: 0; }
.who { display: flex; align-items: center; gap: 8px; color: var(--muted); font-size: 13px; }
.who i {
  width: 26px; height: 26px; border-radius: 50%; background: #eaf0ff; color: var(--brand);
  font-style: normal; font-weight: 600; display: grid; place-items: center; font-size: 12px;
}
.content { padding: 20px 24px 40px; }

/* ---------------- 通用组件 ---------------- */
.card {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 18px 20px; margin-bottom: 16px;
}
.card-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; }
.card-head h2, .card > h2 { font-size: 14.5px; font-weight: 600; margin: 0 0 12px; }
.card-head h2 { margin: 0; }
.link { font-size: 13px; }

.flash {
  padding: 10px 14px; border-radius: 10px; margin-bottom: 14px; font-size: 13px;
  border: 1px solid transparent;
}
.flash.ok { background: #e9f8f1; color: #0b7a55; border-color: #c5ecdc; }
.flash.err { background: #fdeceb; color: #b8322c; border-color: #f7d3d0; }

.empty { padding: 44px 0; text-align: center; color: var(--muted); font-size: 13px; }

.btn {
  border: 1px solid var(--line); background: #fff; color: var(--text); cursor: pointer;
  padding: 8px 15px; border-radius: 9px; font-size: 13px; font-family: inherit;
  display: inline-block; line-height: 1.4; transition: .15s;
}
.btn:hover { border-color: #c9d2e3; background: #f8fafd; text-decoration: none; }
.btn.sm { padding: 5px 11px; font-size: 12.5px; border-radius: 8px; }
.btn.primary { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn.primary:hover { background: var(--brand-dark); }
.btn.ghost { color: var(--muted); }
.btn.danger { color: var(--danger); border-color: #f2d5d3; }
.btn.danger:hover { background: #fdf1f0; border-color: #eab7b3; }
form.inline { display: inline; }
.ops { white-space: nowrap; }
.ops > * { margin-right: 4px; }

/* ---------------- 仪表盘 ---------------- */
.stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; margin-bottom: 16px; }
.stat { background: #fff; border: 1px solid var(--line); border-radius: var(--radius); padding: 16px 18px; }
.stat-label { color: var(--muted); font-size: 12.5px; }
.stat-value { font-size: 26px; font-weight: 650; letter-spacing: -.5px; margin: 4px 0 2px; }
.stat-sub { color: var(--muted); font-size: 12px; }
.stat.ok .stat-value { color: var(--ok); }
.stat.warn .stat-value { color: var(--warn); }

.quick {
  display: flex; align-items: center; gap: 10px; background: #fff;
  border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 18px;
}
.quick > div { margin-right: 6px; }
.quick b { display: block; font-size: 13.5px; }
.quick small { color: var(--muted); font-size: 11.5px; }
.quick input, .quick select {
  border: 1px solid var(--line); border-radius: 8px; padding: 7px 10px;
  font-size: 13px; font-family: inherit; background: #fbfcfe; min-width: 0;
}
.quick input[name=name] { width: 200px; }
.quick input[name=note] { width: 170px; }
.quick button {
  margin-left: auto; background: var(--brand); color: #fff; border: 0; cursor: pointer;
  padding: 8px 18px; border-radius: 8px; font-size: 13px; font-family: inherit;
}
.quick button:hover { background: var(--brand-dark); }

/* ---------------- 表格 ---------------- */
.table { width: 100%; border-collapse: collapse; font-size: 13px; }
.table th {
  text-align: left; font-weight: 500; color: var(--muted); font-size: 12px;
  padding: 9px 10px; border-bottom: 1px solid var(--line); white-space: nowrap;
}
.table td { padding: 11px 10px; border-bottom: 1px solid #f2f4f8; vertical-align: middle; }
.table tbody tr:hover { background: #fafbfe; }
.table tbody tr.unread td { font-weight: 500; }
.table tbody tr:last-child td { border-bottom: 0; }
.table-foot { padding-top: 12px; color: var(--muted); font-size: 12.5px; }

.addr { font-size: 13px; font-weight: 500; color: #111827; }
.note { color: var(--muted); font-size: 12px; margin-top: 2px; }
.copy {
  border: 0; background: transparent; color: #b6c0d1; cursor: pointer; font-size: 13px;
  padding: 0 2px; vertical-align: middle;
}
.copy:hover { color: var(--brand); }
.count { font-weight: 500; }
.badge {
  background: #eef2ff; color: var(--brand); border-radius: 8px; font-size: 11px;
  padding: 1px 6px; margin-left: 4px;
}
.dot-new { display: inline-block; width: 6px; height: 6px; border-radius: 50%; background: var(--danger); }

.pill {
  display: inline-block; font-size: 11.5px; padding: 2px 9px; border-radius: 20px;
  background: #eef1f6; color: #5b6678;
}
.pill.active { background: #e7f7ef; color: #0b7a55; }
.pill.expired { background: #f2f4f7; color: #8a94a6; }
.pill.disabled { background: #fdf2e9; color: #b06810; }
.left { font-size: 12.5px; color: #4b5563; }
.left.warn { color: var(--warn); font-weight: 500; }
.left.expired { color: var(--muted); }

.toolbar { display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px; gap: 12px; flex-wrap: wrap; }
.tab {
  display: inline-block; padding: 6px 13px; border-radius: 8px; font-size: 13px;
  color: var(--muted); border: 1px solid transparent; cursor: pointer; background: transparent;
  font-family: inherit;
}
.tab:hover { color: var(--text); text-decoration: none; }
.tab.on { background: #fff; border-color: var(--line); color: var(--text); font-weight: 500; }
.search { display: flex; gap: 8px; }
.search input {
  border: 1px solid var(--line); border-radius: 8px; padding: 7px 11px; font-size: 13px;
  font-family: inherit; width: 220px; background: #fff;
}
.pager { display: flex; gap: 6px; padding-top: 14px; flex-wrap: wrap; }
.pg {
  min-width: 30px; height: 30px; display: grid; place-items: center; border-radius: 8px;
  border: 1px solid var(--line); font-size: 12.5px; color: var(--text); padding: 0 8px;
}
.pg:hover { background: #f6f8fc; text-decoration: none; }
.pg.on { background: var(--brand); border-color: var(--brand); color: #fff; }
.pg.gap { border: 0; color: var(--muted); }

/* ---------------- 详情页 ---------------- */
.back { display: inline-block; margin-bottom: 12px; font-size: 13px; color: var(--muted); }
.back:hover { color: var(--brand); }
.detail-head { display: flex; justify-content: space-between; gap: 20px; flex-wrap: wrap; align-items: flex-start; }
.dh-addr { font-size: 17px; font-weight: 600; letter-spacing: .2px; }
.dh-meta { display: flex; gap: 14px; align-items: center; flex-wrap: wrap; margin-top: 8px; font-size: 12.5px; }
.dh-ops { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.row-form { display: flex; gap: 8px; }
.row-form select {
  border: 1px solid var(--line); border-radius: 8px; padding: 6px 9px; font-size: 12.5px;
  font-family: inherit; background: #fff;
}

.mail-card { padding: 0; overflow: hidden; }
.mail-head { padding: 18px 20px; border-bottom: 1px solid var(--line); }
.mail-head h2 { margin: 0 0 12px; font-size: 17px; }
.mail-meta { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 8px 18px; }
.mail-meta div { display: flex; gap: 8px; font-size: 12.5px; }
.mail-meta span { color: var(--muted); flex: 0 0 48px; }
.mail-meta b { font-weight: 500; word-break: break-all; }
.mail-tabs { display: flex; align-items: center; gap: 4px; padding: 10px 16px; border-bottom: 1px solid var(--line); background: #fbfcfe; }
.mail-tabs .right { margin-left: auto; }
.mail-text {
  margin: 0; padding: 20px; font: 13px/1.8 "SFMono-Regular", Consolas, monospace;
  white-space: pre-wrap; word-break: break-word; max-height: 70vh; overflow: auto;
}
.mail-frame { width: 100%; height: 70vh; border: 0; background: #fff; }

/* ---------------- 表单 ---------------- */
.form-card > h2 { margin-bottom: 16px; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
label { display: block; font-size: 13px; color: #374151; margin-bottom: 14px; }
label input, label select {
  display: block; width: 100%; margin-top: 6px; border: 1px solid var(--line);
  border-radius: 9px; padding: 9px 12px; font-size: 13.5px; font-family: inherit;
  background: #fbfcfe; color: var(--text);
}
label input:focus, label select:focus {
  outline: none; border-color: #a9c1fb; background: #fff;
  box-shadow: 0 0 0 3px rgba(59,110,245,.1);
}
label small { display: block; color: var(--muted); font-size: 11.5px; margin-top: 5px; font-weight: 400; }
.switch { display: flex; align-items: flex-start; gap: 10px; padding: 12px 0; border-top: 1px dashed #eef1f6; margin-bottom: 0; }
.switch:first-of-type { border-top: 0; }
.switch input { width: auto; margin: 3px 0 0; flex: 0 0 auto; }
.switch span { font-weight: 500; color: var(--text); }
.switch small { margin-top: 2px; }
.form-foot { margin-top: 8px; padding-top: 14px; border-top: 1px solid var(--line); }
.kv { display: flex; justify-content: space-between; padding: 8px 0; border-bottom: 1px solid #f4f6fa; font-size: 13px; }
.kv:last-child { border-bottom: 0; }
.kv span { color: var(--muted); }
.kv b { font-weight: 500; word-break: break-all; text-align: right; }

/* ---------------- 登录页 ---------------- */
.login-body {
  background: radial-gradient(1200px 600px at 15% -10%, #1e3a8a 0%, transparent 55%),
              radial-gradient(900px 500px at 100% 100%, #0b3b6f 0%, transparent 50%),
              #0c1524;
  min-height: 100vh; display: grid; place-items: center; padding: 20px;
}
.login-wrap { width: 100%; max-width: 372px; }
.login-card {
  background: #fff; border-radius: 16px; padding: 32px 30px 26px;
  box-shadow: 0 24px 60px rgba(6, 16, 34, .45);
}
.login-logo {
  width: 46px; height: 46px; border-radius: 13px; margin: 0 auto 16px;
  background: linear-gradient(135deg, #3b6ef5, #6f9bff); color: #fff;
  display: grid; place-items: center; font-size: 22px; font-weight: 700;
}
.login-card h1 { text-align: center; font-size: 19px; margin: 0 0 4px; }
.login-sub { text-align: center; color: var(--muted); font-size: 12.5px; margin: 0 0 20px; }
.login-card label { margin-bottom: 12px; }
.login-card button {
  width: 100%; margin-top: 8px; padding: 11px; border: 0; border-radius: 10px;
  background: var(--brand); color: #fff; font-size: 14px; font-family: inherit;
  letter-spacing: 2px; cursor: pointer;
}
.login-card button:hover { background: var(--brand-dark); }

/* ---------------- 响应式 ---------------- */
@media (max-width: 1080px) {
  .stats { grid-template-columns: repeat(2, 1fr); }
  .grid2 { grid-template-columns: 1fr; }
}
@media (max-width: 760px) {
  .app { flex-direction: column; }
  .sidebar { width: 100%; flex: none; height: auto; position: static; }
  nav { display: flex; gap: 6px; overflow-x: auto; padding: 0 10px 10px; }
  .nav-item { white-space: nowrap; }
  .side-foot { display: none; }
  .content { padding: 14px; }
  .stats { grid-template-columns: 1fr; }
  .quick { flex-wrap: wrap; }
  .quick button { margin-left: 0; }
  .table { display: block; overflow-x: auto; }
}
