:root {
  --bg: #f4f6fb;
  --panel: #ffffff;
  --primary: #3b6ef6;
  --primary-dark: #2f59d6;
  --text: #1f2733;
  --muted: #7a869a;
  --border: #e6eaf2;
  --success: #25b865;
  --danger: #ef4d5a;
  --warning: #f5a623;
  --shadow: 0 6px 24px rgba(30, 50, 90, .08);
}
* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
}
a { color: var(--primary); text-decoration: none; }
.layout { display: flex; min-height: 100vh; }
.sidebar {
  width: 220px; background: #11131a; color: #cfd6e4; padding: 18px 0; flex-shrink: 0;
}
.sidebar .logo { font-size: 18px; font-weight: 700; color: #fff; padding: 0 22px 18px; display: flex; align-items: center; gap: 10px; }
.sidebar .logo span.dot { width: 10px; height: 10px; border-radius: 50%; background: var(--primary); display: inline-block; }
.sidebar nav a {
  display: flex; align-items: center; gap: 10px; padding: 12px 22px; color: #aeb8cc; font-size: 14px;
  border-left: 3px solid transparent;
}
.sidebar nav a:hover { background: #1c1f29; color: #fff; }
.sidebar nav a.active { background: #1c1f29; color: #fff; border-left-color: var(--primary); }
.main { flex: 1; padding: 26px 32px; overflow-x: hidden; }
.topbar { display: flex; align-items: center; justify-content: space-between; margin-bottom: 22px; }
.topbar h1 { font-size: 22px; margin: 0; }
.topbar .sub { color: var(--muted); font-size: 13px; margin-top: 4px; }

.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 16px; margin-bottom: 24px; }
.card { background: var(--panel); border-radius: 14px; padding: 20px; box-shadow: var(--shadow); }
.card .label { color: var(--muted); font-size: 13px; }
.card .value { font-size: 30px; font-weight: 700; margin-top: 8px; }
.card .value.small { font-size: 22px; }

.panel { background: var(--panel); border-radius: 14px; padding: 20px; box-shadow: var(--shadow); margin-bottom: 22px; }
.panel h2 { font-size: 16px; margin: 0 0 14px; }
.panel .panel-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 14px; }
.panel .panel-head h2 { margin: 0; }

.toolbar { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; margin-bottom: 14px; }
.toolbar .spacer { flex: 1; }

input, select, textarea {
  font-family: inherit; font-size: 14px; padding: 9px 11px; border: 1px solid var(--border);
  border-radius: 9px; background: #fff; color: var(--text); outline: none; width: 100%;
}
input:focus, select:focus, textarea:focus { border-color: var(--primary); }
label { display: block; font-size: 13px; color: var(--muted); margin-bottom: 6px; }

.btn {
  display: inline-flex; align-items: center; gap: 6px; padding: 9px 16px; border-radius: 9px; border: 1px solid var(--border);
  background: #fff; color: var(--text); cursor: pointer; font-size: 14px; transition: .15s;
}
.btn:hover { border-color: var(--primary); color: var(--primary); }
.btn.primary { background: var(--primary); color: #fff; border-color: var(--primary); }
.btn.primary:hover { background: var(--primary-dark); color: #fff; }
.btn.danger { color: var(--danger); border-color: #f3c2c6; }
.btn.danger:hover { background: var(--danger); color: #fff; }
.btn.sm { padding: 6px 10px; font-size: 13px; }
.btn:disabled { opacity: .5; cursor: not-allowed; }

table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 11px 12px; border-bottom: 1px solid var(--border); font-size: 13px; }
th { color: var(--muted); font-weight: 600; background: #fafbfe; }
tr:hover td { background: #fafbff; }
.tag { display: inline-block; padding: 2px 9px; border-radius: 20px; font-size: 12px; }
.tag.ok { background: #e6f7ee; color: var(--success); }
.tag.fail { background: #fdeaec; color: var(--danger); }
.tag.wait { background: #fff4e0; color: var(--warning); }
.tag.off { background: #eceff3; color: #8a94a6; }

.card-link { text-decoration: none; color: inherit; cursor: pointer; border: 1px dashed var(--primary); transition: background .15s; }
.card-link:hover { background: #f3f7ff; }
.card-link .value { color: var(--primary); font-size: 14px; }

.group-list { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }
.group-chip { display: inline-flex; align-items: center; gap: 6px; padding: 5px 10px; background: #f2f5fb; border: 1px solid var(--border); border-radius: 20px; font-size: 13px; }
.group-chip b { color: var(--primary); }
.group-chip .x { border: none; background: transparent; cursor: pointer; color: var(--muted); font-size: 13px; padding: 0 2px; line-height: 1; }
.group-chip .x:hover { color: var(--danger); }

.pager { display: flex; align-items: center; gap: 10px; justify-content: flex-end; margin-top: 14px; }
.pager .info { color: var(--muted); }

.modal-mask { position: fixed; inset: 0; background: rgba(20, 25, 40, .45); display: none; align-items: center; justify-content: center; z-index: 50; }
.modal-mask.show { display: flex; }
.modal { background: #fff; border-radius: 14px; width: 560px; max-width: 94vw; max-height: 92vh; overflow: auto; box-shadow: var(--shadow); }
.modal .modal-head { padding: 18px 22px; border-bottom: 1px solid var(--border); font-weight: 700; font-size: 16px; display: flex; justify-content: space-between; }
.modal .modal-body { padding: 20px 22px; }
.modal .modal-foot { padding: 16px 22px; border-top: 1px solid var(--border); display: flex; justify-content: flex-end; gap: 10px; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; margin-bottom: 14px; }
.form-row.full { grid-template-columns: 1fr; }

.toast-wrap { position: fixed; top: 20px; right: 20px; z-index: 100; display: flex; flex-direction: column; gap: 10px; }
.toast { background: #11131a; color: #fff; padding: 12px 18px; border-radius: 10px; font-size: 14px; box-shadow: var(--shadow); animation: slidein .2s; }
.toast.ok { background: #1f9d57; }
.toast.err { background: #d93b47; }
@keyframes slidein { from { opacity: 0; transform: translateX(20px); } to { opacity: 1; transform: none; } }

.progress { height: 10px; background: #eef1f7; border-radius: 20px; overflow: hidden; }
.progress > i { display: block; height: 100%; width: 0; background: linear-gradient(90deg, var(--primary), #6a92ff); transition: width .25s; }

.muted { color: var(--muted); }
.right { text-align: right; }
.nowrap { white-space: nowrap; }
code.k { background: #eef1f7; padding: 1px 6px; border-radius: 5px; color: var(--primary-dark); font-size: 12px; }
.var-chip { display: inline-block; padding: 4px 9px; margin: 4px 4px 0 0; background: #eef3ff; color: var(--primary-dark); border-radius: 7px; font-size: 12px; cursor: pointer; border: 1px solid #dbe5ff; }
.var-chip:hover { background: #e0eaff; }
.vars-box { background: #fafbff; border: 1px dashed var(--border); border-radius: 10px; padding: 12px; margin-top: 10px; }
.vars-box h4 { margin: 8px 0 4px; font-size: 13px; color: var(--muted); }
#editor { height: 340px; background: #fff; }
#previewBox { border: 1px solid var(--border); border-radius: 10px; padding: 14px; min-height: 120px; background: #fff; }
.kv-row { display: grid; grid-template-columns: 1fr 1fr auto; gap: 10px; margin-bottom: 8px; }
.chart-box { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
@media (max-width: 760px){ .chart-box{ grid-template-columns:1fr; } .form-row{grid-template-columns:1fr;} }

/* 侧栏用户区 */
.sidebar .user-box { position: absolute; bottom: 0; left: 0; right: 0; padding: 14px 22px; border-top: 1px solid #23262f; }
.sidebar { position: relative; }
.ub-row { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; }
.ub-name { color: #fff; font-weight: 600; }
.ub-role { font-size: 11px; background: var(--primary); color: #fff; border-radius: 8px; padding: 1px 7px; }
.sidebar .user-box .btn.sm { width: 100%; }

/* 代码模式编辑器 */
.editor-toolbar { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; }
.editor-toolbar label { font-weight: 600; color: #444; }
.code-editor {
  width: 100%; min-height: 360px; box-sizing: border-box; padding: 14px; border: 1px solid var(--border);
  border-radius: 8px; font-family: "SFMono-Regular", Consolas, "Liberation Mono", Menlo, monospace;
  font-size: 13px; line-height: 1.5; resize: vertical; background: #1e1e1e; color: #d4d4d4;
}
#editor { background: #fff; border-radius: 6px; }

/* 发送队列页 */
.tabs { display: flex; gap: 8px; margin-bottom: 14px; flex-wrap: wrap; }
.tabs .tab { padding: 8px 16px; border-radius: 9px; border: 1px solid var(--border); background: #fff; color: var(--muted); cursor: pointer; font-size: 14px; }
.tabs .tab.active { background: var(--primary); color: #fff; border-color: var(--primary); }
.tabs .tab .badge { display: inline-block; min-width: 18px; padding: 0 6px; margin-left: 6px; border-radius: 10px; background: rgba(0,0,0,.12); font-size: 12px; text-align: center; }
.tabs .tab.active .badge { background: rgba(255,255,255,.25); }
.kv-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 14px; }
.kv-grid > div { background: #fafbff; border: 1px solid var(--border); border-radius: 10px; padding: 12px; line-height: 1.7; }
.kv-grid b { color: var(--text); }
pre.code-editor { white-space: pre-wrap; word-break: break-all; }

/* 登录页 */
.login-body { background: linear-gradient(135deg,#3b6ef6,#2f59d6); min-height: 100vh; display: flex; align-items: center; justify-content: center; }
.login-card { background: #fff; border-radius: 14px; box-shadow: 0 12px 40px rgba(0,0,0,.2); padding: 36px; width: 360px; max-width: 92vw; }
.login-card h1 { margin: 0 0 4px; font-size: 22px; }
.login-card .sub { color: var(--muted); margin-bottom: 22px; }
.login-card label { display: block; font-size: 13px; margin: 12px 0 5px; color: #555; }
.login-card input { width: 100%; box-sizing: border-box; padding: 10px 12px; border: 1px solid var(--border); border-radius: 8px; font-size: 14px; }
.login-card .btn { width: 100%; margin-top: 18px; }
.login-card #err { color: var(--danger); margin-top: 12px; min-height: 18px; }
