/* Mailer V2 设计系统 */
:root {
  --bg: #f5f7fa;
  --card: #fff;
  --line: #e4e8ee;
  --line2: #eef1f5;
  --text: #1a2332;
  --sub: #5a6878;
  --muted: #97a2b1;
  --brand: #1e6fd9;
  --brand-dark: #1857ab;
  --ok: #0d9f6e;
  --ok-bg: #ecfdf5;
  --err: #dc3545;
  --err-bg: #fef2f2;
  --warn: #d97706;
  --warn-bg: #fffbeb;
  --info: #0ea5e9;
  --info-bg: #f0f9ff;
  --purple: #7c3aed;
  --purple-bg: #f5f3ff;
  --radius: 10px;
  --shadow: 0 1px 3px rgba(16,24,40,.06), 0 1px 2px rgba(16,24,40,.04);
}

* { margin: 0; padding: 0; box-sizing: border-box; }

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
               "Microsoft YaHei", sans-serif;
  background: var(--bg); color: var(--text);
  font-size: 14px; line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

/* 布局 */
.layout { display: flex; min-height: 100vh; }

.sidebar {
  width: 210px; background: #1a2332; color: #c8d3e0;
  flex-shrink: 0; display: flex; flex-direction: column;
  position: fixed; top: 0; left: 0; bottom: 0; z-index: 200;
  transition: transform .25s;
}
.sidebar .brand {
  padding: 17px 17px 15px; display: flex; align-items: center; gap: 10px;
  border-bottom: 1px solid rgba(255,255,255,.08);
}
.sidebar .brand .logo {
  width: 29px; height: 29px; border-radius: 8px;
  background: linear-gradient(135deg,#1e6fd9,#3b8de8);
  display: flex; align-items: center; justify-content: center;
  font-size: 14px; font-weight: 700; color: #fff;
}
.sidebar .brand .t { font-size: 14.5px; font-weight: 600; color: #fff; }
.sidebar .brand .v { font-size: 10px; color: #6b7c93; }

.nav { flex: 1; overflow-y: auto; padding: 8px 0; }
.nav::-webkit-scrollbar { width: 4px; }
.nav::-webkit-scrollbar-thumb { background: #2d3b4f; border-radius: 2px; }

.nav-item {
  display: flex; align-items: center; gap: 9px;
  padding: 9px 17px; font-size: 13px; color: #a8b6c8;
  cursor: pointer; text-decoration: none; transition: .15s;
  border-left: 3px solid transparent;
}
.nav-item:hover { background: rgba(255,255,255,.05); color: #fff; }
.nav-item.on {
  background: rgba(30,111,217,.18); color: #fff;
  border-left-color: var(--brand); font-weight: 550;
}
.nav-item .ico { width: 15px; text-align: center; opacity: .85; }

.nav-group {
  padding: 13px 17px 5px; font-size: 10px; color: #5f6f85;
  text-transform: uppercase; letter-spacing: .5px; font-weight: 600;
}

.sidebar .foot {
  padding: 11px 15px; border-top: 1px solid rgba(255,255,255,.08);
  font-size: 11px; color: #6b7c93;
}
.dot { display: inline-block; width: 6px; height: 6px; border-radius: 50%; background: var(--ok); margin-right: 5px; }
.dot.bad { background: var(--err); }

.main { flex: 1; margin-left: 210px; display: flex; flex-direction: column; min-width: 0; }

.topbar {
  height: 55px; background: #fff; border-bottom: 1px solid var(--line);
  display: flex; align-items: center; padding: 0 20px; gap: 14px;
  position: sticky; top: 0; z-index: 100;
}
.topbar .page-title { font-size: 15px; font-weight: 600; }
.topbar .spacer { flex: 1; }

.user-chip {
  display: flex; align-items: center; gap: 7px; padding: 5px 11px;
  border-radius: 20px; background: var(--line2); font-size: 12.5px;
  cursor: pointer; transition: .15s;
}
.user-chip:hover { background: #e4e8ee; }
.user-chip .av {
  width: 21px; height: 21px; border-radius: 50%; background: var(--brand);
  color: #fff; display: flex; align-items: center; justify-content: center;
  font-size: 11px; font-weight: 600;
}

.content { flex: 1; padding: 18px 20px 40px; }

/* 卡片 */
.card {
  background: var(--card); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 15px 17px; margin-bottom: 13px;
  box-shadow: var(--shadow);
}
.card-head {
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px; flex-wrap: wrap; margin-bottom: 13px;
}
.card-title { font-size: 13.5px; font-weight: 600; }
.card-desc { font-size: 11.5px; color: var(--muted); margin-top: 2px; font-weight: 400; }

/* KPI */
.kpis { display: grid; grid-template-columns: repeat(auto-fit,minmax(140px,1fr)); gap: 11px; margin-bottom: 13px; }
.kpi {
  background: #fff; border: 1px solid var(--line); border-radius: var(--radius);
  padding: 14px 15px; box-shadow: var(--shadow); position: relative; overflow: hidden;
}
.kpi::before {
  content: ''; position: absolute; top: 0; left: 0; right: 0;
  height: 3px; background: var(--brand);
}
.kpi.ok::before { background: var(--ok); }
.kpi.err::before { background: var(--err); }
.kpi.warn::before { background: var(--warn); }
.kpi.info::before { background: var(--info); }
.kpi.purple::before { background: var(--purple); }
.kpi .v { font-size: 25px; font-weight: 700; line-height: 1.1; font-variant-numeric: tabular-nums; }
.kpi.ok .v { color: var(--ok); }
.kpi.err .v { color: var(--err); }
.kpi.warn .v { color: var(--warn); }
.kpi.info .v { color: var(--info); }
.kpi.purple .v { color: var(--purple); }
.kpi .k { font-size: 11.5px; color: var(--muted); margin-top: 4px; }
.kpi .sub { font-size: 10.5px; color: var(--muted); margin-top: 2px; }

/* 表格 */
.tbl-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
table.tbl { width: 100%; border-collapse: collapse; font-size: 13px; }
table.tbl th {
  text-align: left; padding: 9px 10px; font-size: 11.5px; font-weight: 600;
  color: var(--muted); border-bottom: 1px solid var(--line);
  white-space: nowrap; background: #fafbfc; position: sticky; top: 0; z-index: 5;
}
table.tbl td { padding: 9px 10px; border-bottom: 1px solid var(--line2); vertical-align: middle; }
table.tbl tr:hover td { background: #fafbfc; }
table.tbl td.num { font-variant-numeric: tabular-nums; }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12px; }

/* 标签 */
.tag {
  display: inline-block; font-size: 11px; padding: 2.5px 8px;
  border-radius: 5px; font-weight: 600; white-space: nowrap;
}
.tag.ok { background: var(--ok-bg); color: var(--ok); }
.tag.err { background: var(--err-bg); color: var(--err); }
.tag.warn { background: var(--warn-bg); color: var(--warn); }
.tag.info { background: var(--info-bg); color: var(--info); }
.tag.purple { background: var(--purple-bg); color: var(--purple); }
.tag.gray { background: var(--line2); color: var(--sub); }

/* 按钮 */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 5px;
  padding: 8px 16px; border-radius: 8px; border: none;
  font-size: 13px; font-weight: 550; font-family: inherit;
  cursor: pointer; transition: .15s; white-space: nowrap;
  background: var(--brand); color: #fff;
}
.btn:hover { background: var(--brand-dark); }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn-sec { background: var(--line2); color: var(--sub); }
.btn-sec:hover { background: #e4e8ee; color: var(--text); }
.btn-ok { background: var(--ok); }
.btn-ok:hover { background: #0a8058; }
.btn-err { background: var(--err); }
.btn-err:hover { background: #b02a37; }
.btn-warn { background: var(--warn); }
.btn-warn:hover { background: #b45309; }
.btn-sm { padding: 6px 12px; font-size: 12.5px; border-radius: 7px; }
.btn-xs { padding: 4px 9px; font-size: 11.5px; border-radius: 6px; }
.btn-block { width: 100%; }

/* 表单 */
.field { margin-bottom: 13px; }
.lbl { display: block; font-size: 12.5px; color: var(--sub); margin-bottom: 5px; font-weight: 500; }
.lbl .req { color: var(--err); }

input[type=text], input[type=password], input[type=number], input[type=email],
input[type=date], input[type=datetime-local], select, textarea {
  width: 100%; padding: 9px 12px; border: 1px solid var(--line);
  border-radius: 8px; font-size: 13.5px; font-family: inherit;
  background: #fff; color: var(--text); transition: .15s; outline: none;
}
input:focus, select:focus, textarea:focus {
  border-color: var(--brand); box-shadow: 0 0 0 3px rgba(30,111,217,.1);
}
textarea { min-height: 110px; resize: vertical; line-height: 1.6; }

.bar { display: flex; gap: 9px; flex-wrap: wrap; align-items: flex-end; }
.bar > * { flex: 0 0 auto; }

/* 空态/加载 */
.empty { text-align: center; padding: 42px 20px; color: var(--muted); font-size: 13px; }
.empty .ico { font-size: 30px; opacity: .35; margin-bottom: 9px; }
.loading-box { padding: 38px; text-align: center; color: var(--muted); font-size: 13px; }
.spin {
  display: inline-block; width: 13px; height: 13px;
  border: 2px solid rgba(30,111,217,.25); border-top-color: var(--brand);
  border-radius: 50%; animation: sp .7s linear infinite;
  vertical-align: -2px; margin-right: 5px;
}
@keyframes sp { to { transform: rotate(360deg); } }

/* 消息 */
.msg {
  font-size: 13px; padding: 10px 13px; border-radius: 8px;
  margin-top: 11px; display: none;
}
.msg.show { display: block; }
.msg.ok { background: var(--ok-bg); color: var(--ok); }
.msg.err { background: var(--err-bg); color: var(--err); }
.msg.warn { background: var(--warn-bg); color: var(--warn); }
.msg.info { background: var(--info-bg); color: var(--info); }

/* 弹窗 */
.modal-mask {
  position: fixed; inset: 0; background: rgba(16,24,40,.5);
  z-index: 1000; display: none; align-items: center; justify-content: center;
  padding: 18px; backdrop-filter: blur(2px);
}
.modal-mask.show { display: flex; }
.modal {
  background: #fff; border-radius: 12px; width: 100%; max-width: 560px;
  max-height: 88vh; overflow-y: auto; box-shadow: 0 20px 40px rgba(0,0,0,.2);
  animation: modalIn .18s ease-out;
}
@keyframes modalIn {
  from { opacity: 0; transform: translateY(-8px) scale(.98); }
  to { opacity: 1; transform: none; }
}
.modal-head {
  padding: 15px 19px; border-bottom: 1px solid var(--line);
  display: flex; align-items: center; justify-content: space-between;
}
.modal-title { font-size: 14.5px; font-weight: 600; }
.modal-close {
  width: 27px; height: 27px; border-radius: 7px; border: none;
  background: var(--line2); color: var(--sub); cursor: pointer; font-size: 16px; line-height: 1;
}
.modal-close:hover { background: var(--line); }
.modal-body { padding: 17px 19px; }
.modal-foot {
  padding: 13px 19px; border-top: 1px solid var(--line);
  display: flex; gap: 9px; justify-content: flex-end;
}

/* 进度条 */
.progress { height: 6px; background: var(--line2); border-radius: 3px; overflow: hidden; }
.progress .fill { height: 100%; background: var(--brand); border-radius: 3px; transition: width .3s; }

/* 分页 */
.pager {
  display: flex; align-items: center; justify-content: flex-end;
  gap: 7px; padding-top: 13px; font-size: 12.5px;
}
.pager .info { color: var(--muted); margin-right: auto; }

/* Toast */
#toast-box {
  position: fixed; top: 18px; right: 18px; z-index: 2000;
  display: flex; flex-direction: column; gap: 7px;
}
.toast {
  background: #fff; border-radius: 9px; box-shadow: 0 6px 16px rgba(0,0,0,.14);
  padding: 11px 15px; font-size: 13px; min-width: 210px; max-width: 350px;
  border-left: 3px solid var(--brand); animation: toastIn .2s ease-out;
}
@keyframes toastIn { from { opacity: 0; transform: translateX(18px); } to { opacity: 1; transform: none; } }
.toast.ok { border-left-color: var(--ok); }
.toast.err { border-left-color: var(--err); }
.toast.warn { border-left-color: var(--warn); }

/* 工具类 */
.row { display: flex; gap: 11px; flex-wrap: wrap; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 13px; }
.grid3 { display: grid; grid-template-columns: repeat(3,1fr); gap: 13px; }
.mt8 { margin-top: 8px; } .mt12 { margin-top: 12px; } .mt16 { margin-top: 16px; }
.mb12 { margin-bottom: 12px; }
.text-muted { color: var(--muted); }
.text-ok { color: var(--ok); }
.text-err { color: var(--err); }
.text-sm { font-size: 12px; }
.bold { font-weight: 600; }
.nowrap { white-space: nowrap; }
.hidden { display: none !important; }
.flex-end { display: flex; justify-content: flex-end; gap: 7px; }

.menu-btn { display: none; }

/* 手机 */
@media (max-width: 900px) {
  .sidebar { transform: translateX(-100%); }
  .sidebar.open { transform: translateX(0); }
  .main { margin-left: 0; }
  .menu-btn {
    display: flex; width: 33px; height: 33px; align-items: center;
    justify-content: center; border: 1px solid var(--line);
    border-radius: 8px; background: #fff; cursor: pointer; font-size: 16px;
  }
  .content { padding: 13px 11px 60px; }
  .topbar { padding: 0 11px; height: 51px; }
  .kpis { grid-template-columns: repeat(2,1fr); gap: 8px; }
  .kpi { padding: 12px 11px; }
  .kpi .v { font-size: 20px; }
  .grid2, .grid3 { grid-template-columns: 1fr; }
  .card { padding: 12px 12px; }
  table.tbl { font-size: 12.5px; min-width: 620px; }
  table.tbl th, table.tbl td { padding: 8px 7px; }
  .bar { flex-direction: column; align-items: stretch; }
  .bar > * { width: 100%; }
  .modal { max-width: 100%; }
  input, select, textarea { font-size: 16px !important; }
  #toast-box { left: 11px; right: 11px; top: 11px; }
  .toast { max-width: 100%; }
  .pager { justify-content: center; flex-wrap: wrap; }
  .pager .info { width: 100%; text-align: center; margin-bottom: 5px; }
}
