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

:root {
  --primary: #667eea;
  --primary-2: #764ba2;
  --ink: #2c3e50;
  --muted: #6b7280;
  --line: #e1e5e9;
}

body {
  font-family: 'Microsoft YaHei', 'PingFang SC', system-ui, -apple-system, sans-serif;
  background: linear-gradient(135deg, #f5f7fa 0%, #c3cfe2 100%);
  min-height: 100vh;
  color: #333;
  line-height: 1.6;
  padding-bottom: 40px;
}

.hidden { display: none !important; }

/* ---------- 登录 ---------- */
.login-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
}

.login-card {
  width: 100%;
  max-width: 420px;
  padding: 38px 34px;
  background: rgba(255, 255, 255, 0.97);
  border-radius: 20px;
  box-shadow: 0 20px 45px rgba(0, 0, 0, 0.18);
  animation: rise 0.5s ease;
}

@keyframes rise {
  from { transform: translateY(24px); opacity: 0; }
  to { transform: translateY(0); opacity: 1; }
}

.login-head { text-align: center; margin-bottom: 26px; }
.login-icon { font-size: 56px; display: block; margin-bottom: 10px; }
.login-head h2 { font-size: 26px; color: #333; }
.login-head p { color: var(--muted); font-size: 14px; }
.login-foot {
  margin-top: 22px;
  padding-top: 18px;
  border-top: 1px solid #eee;
  font-size: 12px;
  color: var(--muted);
  text-align: center;
  line-height: 1.7;
}

/* ---------- 布局 ---------- */
.container { max-width: 1180px; margin: 0 auto; padding: 22px 20px; }

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 22px;
}
.topbar h2 {
  font-size: 1.9em;
  color: var(--ink);
  font-weight: 600;
  text-shadow: 0 2px 4px rgba(0, 0, 0, 0.06);
}

.tabs {
  display: flex;
  gap: 6px;
  background: #fff;
  border-radius: 15px;
  padding: 8px;
  margin-bottom: 24px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
  flex-wrap: wrap;
}

.tab {
  flex: 1 1 180px;
  padding: 13px 16px;
  border: 2px solid transparent;
  border-radius: 10px;
  background: transparent;
  color: #666;
  font-size: 15px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.25s ease;
  font-family: inherit;
}
.tab:hover { background: rgba(102, 126, 234, 0.1); color: var(--primary); }
.tab.active {
  background: linear-gradient(135deg, var(--primary) 0%, var(--primary-2) 100%);
  color: #fff;
  box-shadow: 0 3px 12px rgba(102, 126, 234, 0.25);
}

.panel { display: none; }
.panel.active {
  display: block;
  background: #fff;
  border-radius: 20px;
  padding: 28px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.08);
  animation: fade 0.35s ease;
}
@keyframes fade {
  from { opacity: 0; transform: translateY(12px); }
  to { opacity: 1; transform: translateY(0); }
}

h3 {
  color: var(--ink);
  font-size: 1.45em;
  font-weight: 600;
  border-left: 4px solid var(--primary);
  padding-left: 14px;
  margin-bottom: 22px;
}

h4 { color: var(--ink); font-size: 1.15em; font-weight: 600; margin-bottom: 18px; }
h5 { color: var(--ink); font-size: 1em; margin-bottom: 12px; }

.card {
  background: linear-gradient(135deg, #f8f9ff 0%, #f0f2ff 100%);
  border: 1px solid rgba(102, 126, 234, 0.12);
  border-radius: 15px;
  padding: 24px;
  margin-bottom: 22px;
}

/* ---------- 表单 ---------- */
.field { margin-bottom: 18px; }
.field label { display: block; margin-bottom: 7px; color: #555; font-weight: 500; font-size: 14px; }

input[type='text'], input[type='password'], select, textarea {
  width: 100%;
  padding: 11px 14px;
  border: 2px solid var(--line);
  border-radius: 10px;
  font-size: 14px;
  font-family: inherit;
  background: #fff;
  transition: all 0.2s ease;
}
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.12);
}
input.invalid, textarea.invalid { border-color: #ff6b6b; }

.narrow { max-width: 220px; }
.wide { max-width: 430px; }
textarea { min-height: 220px; resize: vertical; font-family: 'Courier New', monospace; font-size: 13px; line-height: 1.5; }

.hint { font-size: 12px; color: var(--muted); margin-top: 6px; }
.hint b { color: #444; }
.hint.error { color: #e53935; }
.hint.ok { color: #2e7d32; }
.hint code { background: #f3f4f8; padding: 1px 5px; border-radius: 4px; font-size: 12px; color: #444; }

.field-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 7px;
}
.field-head label { margin-bottom: 0; }
.btn.mini { padding: 3px 10px; font-size: 12px; box-shadow: none; }

/* ---------- 按钮 ---------- */
.btn {
  padding: 10px 22px;
  border: none;
  border-radius: 10px;
  font-size: 14px;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  transition: all 0.2s ease;
  margin: 4px 6px 4px 0;
}
.btn.primary { background: linear-gradient(135deg, #4CAF50 0%, #45a049 100%); color: #fff; }
.btn.primary:hover { transform: translateY(-1px); box-shadow: 0 6px 16px rgba(76, 175, 80, 0.3); }
.btn.danger { background: linear-gradient(135deg, #ff6b6b 0%, #ee5a52 100%); color: #fff; }
.btn.danger:hover { transform: translateY(-1px); box-shadow: 0 6px 16px rgba(255, 107, 107, 0.3); }
.btn.ghost { background: #fff; color: var(--primary); border: 1px solid rgba(102, 126, 234, 0.4); }
.btn.ghost:hover { background: rgba(102, 126, 234, 0.08); }
.btn.block { width: 100%; padding: 13px; font-size: 15px; }
.btn:disabled { opacity: 0.6; cursor: not-allowed; }

/* ---------- 提示框 ---------- */
.alert {
  padding: 12px 16px;
  border-radius: 10px;
  margin-bottom: 18px;
  font-size: 14px;
  font-weight: 500;
  border-left: 4px solid;
}
.alert.ok { background: #e8f5e9; border-color: #4CAF50; color: #256d29; }
.alert.err { background: #ffebee; border-color: #f44336; color: #b02a22; }
.alert.info { background: #e3f2fd; border-color: #2196F3; color: #14578f; }

.box {
  border-radius: 12px;
  padding: 18px 20px;
  margin: 16px 0;
  border-left: 4px solid;
  font-size: 14px;
}
.box.info { background: linear-gradient(135deg, #e3f2fd 0%, #bbdefb 100%); border-color: #2196F3; }
.box.warn { background: linear-gradient(135deg, #fff3e0 0%, #ffe0b2 100%); border-color: #ff9800; }
.box.danger { background: linear-gradient(135deg, #ffebee 0%, #ffcdd2 100%); border-color: #f44336; }
.box ul { margin: 8px 0 0 20px; }
.box li { margin: 5px 0; }

.badges { display: inline-flex; gap: 6px; flex-wrap: wrap; margin-left: 6px; }
.badge {
  display: inline-block;
  background: #fff;
  border: 1px solid #e0e0e0;
  border-radius: 6px;
  padding: 1px 8px;
  font-size: 12px;
  font-weight: 600;
  color: #c62828;
}

/* ---------- 分组列表 ---------- */
.group-list { display: grid; gap: 12px; margin-top: 14px; }

.group-item {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  background: linear-gradient(135deg, #f8f9fa 0%, #eef1f6 100%);
  border: 1px solid rgba(0, 0, 0, 0.05);
  border-radius: 12px;
  padding: 13px 16px;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}
.group-item:hover { transform: translateX(3px); box-shadow: 0 5px 16px rgba(0, 0, 0, 0.08); }

.gname {
  font-weight: 700;
  color: #1a237e;
  font-size: 15px;
  cursor: pointer;
  padding: 3px 0;
}
.gname:hover { text-decoration: underline; }

.chip {
  background: #fff;
  border: 1px solid #ddd;
  border-radius: 6px;
  padding: 4px 9px;
  font-size: 12.5px;
  font-weight: 600;
  color: #37474f;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.06);
}
.chip.count { font-weight: 500; color: #546e7a; }
.chip.tag { font-weight: 500; color: #7e57c2; }

.spacer { flex: 1 1 auto; }

.edit-area {
  margin: -4px 0 6px;
  padding: 20px;
  background: linear-gradient(135deg, #fafbff 0%, #f0f4ff 100%);
  border: 2px dashed var(--primary);
  border-radius: 12px;
}
.edit-area textarea { min-height: 300px; }

.target-list { margin-top: 8px; line-height: 1.9; }
.target-list code {
  background: #fff;
  border: 1px solid #ddd;
  border-radius: 5px;
  padding: 2px 7px;
  font-size: 13px;
}

/* ---------- 统计 ---------- */
.stats {
  background: linear-gradient(135deg, #e8f5e8 0%, #c8e6c9 100%);
  border: 1px solid rgba(76, 175, 80, 0.2);
  border-radius: 15px;
  padding: 18px 20px;
  margin-top: 18px;
  display: flex;
  gap: 26px;
  flex-wrap: wrap;
  font-size: 14px;
  color: #33553a;
}
.stats strong { font-size: 17px; color: #1b5e20; display: block; }

/* ---------- 输出链接 ---------- */
.link-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  background: #fff;
  border-left: 4px solid var(--primary);
  border-radius: 10px;
  padding: 16px 18px;
  margin-bottom: 12px;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.05);
  flex-wrap: wrap;
}
.out-link {
  display: block;
  color: var(--primary);
  font-weight: 500;
  word-break: break-all;
  text-decoration: none;
  font-size: 13.5px;
}
.out-link:hover { text-decoration: underline; }

.foot {
  text-align: center;
  color: var(--muted);
  font-size: 13px;
  margin-top: 26px;
  line-height: 1.8;
}

@media (max-width: 720px) {
  .container { padding: 14px 12px; }
  .panel { padding: 18px; }
  .topbar h2 { font-size: 1.3em; }
  .tab { flex: 1 1 100%; }
  .narrow, .wide { max-width: 100%; }
  .stats { gap: 16px; }

  /* 手机端：分组项竖排、去掉 hover 位移、长地址允许换行 */
  .group-item { flex-direction: column; align-items: stretch; gap: 8px; }
  .group-item:hover { transform: none; box-shadow: none; }
  .group-item .spacer { display: none; }
  .group-item .btn { width: 100%; }
  .target-list code, .out-link { word-break: break-all; }
  .link-row { flex-direction: column; align-items: stretch; gap: 10px; }
  .link-row .btn { width: 100%; }
  .edit-area { padding: 14px; }
  .edit-area textarea { min-height: 240px; }
  .field-head { flex-wrap: wrap; }
  .check-row .hint { margin-left: 0; }
  .panel h3 { font-size: 1.05em; }
}

/* ---------- 输出设置 ---------- */
.check-row { margin-bottom: 16px; }
.check {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 14.5px;
  font-weight: 600;
  color: #333;
  cursor: pointer;
}
.check input[type='checkbox'] {
  width: 17px;
  height: 17px;
  accent-color: var(--primary);
  cursor: pointer;
}
.check-row .hint { margin-left: 25px; }
