/* 聚合中转台 · 子链接管理
   视觉：暖棕 + 米白（对齐猪咪后台风格），纯手写，无外部依赖 */
:root {
  --brown: #b88955;
  --brown-2: #a97b49;
  --brown-3: #8f673d;
  --ink: #2b2118;
  --ink-2: #4b3b2b;
  --muted: #6f5b45;
  --muted-2: #907f6b;
  --bg: #fff9f1;
  --card: #fffdf9;
  --thead: #f8efe3;
  --line: rgba(176, 146, 109, .16);
  --line-2: rgba(176, 146, 109, .28);
  --green: #23c342;
  --green-bg: #e9f9ec;
  --green-line: #d3f3d9;
  --orange: #ff9a2e;
  --red: #e45656;
  --sidebar: #161310;
  --sidebar-2: #1b1713;
  --shadow: 0 2px 12px rgba(43, 33, 24, .07);
  --radius: 8px;
  --font: "Helvetica Neue", Helvetica, "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; height: 100%; }
body {
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font);
  font-size: 14px;
  -webkit-font-smoothing: antialiased;
}
a { color: inherit; text-decoration: none; }
button, input, select, textarea { font-family: inherit; font-size: 13px; color: var(--ink); }
button { cursor: pointer; }
[hidden] { display: none !important; }

/* ---------- 侧边栏 ---------- */
.app { min-height: 100%; }
.sidebar {
  position: fixed; left: 0; top: 0; bottom: 0; width: 210px; z-index: 30;
  background: var(--sidebar);
  display: flex; flex-direction: column;
  box-shadow: 2px 0 8px rgba(22, 19, 16, .18);
}
.logo {
  height: 50px; flex: 0 0 50px;
  display: flex; align-items: center; gap: 9px;
  padding: 0 16px;
  background: var(--sidebar-2);
  border-bottom: 1px solid rgba(255, 248, 239, .06);
}
.logo-mark {
  width: 26px; height: 26px; border-radius: 7px;
  display: inline-flex; align-items: center; justify-content: center;
  background: linear-gradient(135deg, #d7ae7a, #a97b49);
  color: #241a11; font-size: 10px; font-weight: 800; letter-spacing: .3px;
}
.logo-text { color: #f2e7d8; font-size: 15px; font-weight: 600; letter-spacing: .4px; }
.nav { padding: 10px 8px; display: flex; flex-direction: column; gap: 2px; }
.nav-item {
  position: relative;
  display: flex; align-items: center; gap: 10px;
  height: 42px; padding: 0 12px; border-radius: 6px;
  color: #b9ad9f; font-size: 13.5px;
  transition: background .15s, color .15s;
}
.nav-item svg { opacity: .75; }
.nav-item:hover { background: rgba(184, 137, 85, .10); color: #eadac4; }
.nav-item.active {
  background: linear-gradient(90deg, rgba(184, 137, 85, .24), rgba(184, 137, 85, .06));
  color: #f5e7d2;
}
.nav-item.active::before {
  content: ""; position: absolute; left: -8px; top: 9px; bottom: 9px; width: 3px;
  border-radius: 0 3px 3px 0; background: var(--brown);
}
.nav-item.active svg { opacity: 1; }
.sidebar-foot {
  margin-top: auto; padding: 14px 16px; font-size: 11px; color: #7c7062;
  border-top: 1px solid rgba(255, 248, 239, .06);
}

/* ---------- 主区域 ---------- */
.main { margin-left: 210px; min-height: 100vh; }
.navbar {
  height: 50px; display: flex; align-items: center; justify-content: space-between;
  padding: 0 18px; background: var(--bg);
  border-bottom: 1px solid var(--line);
}
.crumb { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--muted-2); }
.crumb a { color: var(--muted-2); }
.crumb a:hover { color: var(--brown); }
.crumb i { font-style: normal; color: rgba(111, 91, 69, .45); }
.crumb b { color: var(--ink); font-weight: 500; }
.navbar-right { display: flex; align-items: center; gap: 12px; }
.relay-pill {
  display: inline-flex; align-items: center; gap: 6px;
  height: 24px; padding: 0 10px; border-radius: 12px;
  font-size: 12px; background: #f3ece3; color: var(--muted);
}
.relay-pill em { width: 7px; height: 7px; border-radius: 50%; background: #b9ad9f; }
.relay-pill.on { background: var(--green-bg); color: #1d9c35; border: 1px solid var(--green-line); }
.relay-pill.on em { background: var(--green); box-shadow: 0 0 0 3px rgba(35, 195, 67, .14); }
.relay-pill.off em { background: #c0aa93; }

.tagsbar {
  height: 34px; display: flex; align-items: center; gap: 8px;
  padding: 0 14px; background: var(--bg); border-bottom: 1px solid var(--line);
}
.page-tag {
  display: inline-flex; align-items: center; gap: 6px;
  height: 24px; padding: 0 9px; border-radius: 3px;
  background: #fff; border: 1px solid var(--line-2);
  font-size: 12px; color: var(--muted);
}
.page-tag.active { background: #f3e7d7; border-color: #e3cdb2; color: var(--ink); }
.page-tag b { font-weight: 400; color: var(--muted-2); transform: scale(.9); }

.content { padding: 18px 24px 32px; }

/* ---------- 卡片 ---------- */
.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
}
.page-head {
  display: flex; align-items: center; gap: 12px;
  padding: 16px 22px 10px;
}
.page-title { display: flex; align-items: baseline; gap: 10px; min-width: 0; }
.page-title strong { font-size: 18px; font-weight: 600; color: var(--ink); }
.page-title span { font-size: 12px; color: var(--muted-2); }
.page-head .btn.circle { margin-left: auto; }

/* ---------- 按钮 ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 5px;
  height: 32px; padding: 0 14px; border-radius: 4px;
  border: 1px solid transparent; background: transparent;
  font-size: 13px; font-weight: 500; white-space: nowrap;
  transition: background .15s, border-color .15s, color .15s, box-shadow .15s;
  user-select: none;
}
.btn.primary { background: var(--brown); border-color: var(--brown); color: #fff; }
.btn.primary:hover { background: var(--brown-2); border-color: var(--brown-2); }
.btn.primary:active { background: var(--brown-3); }
.btn.primary[disabled] { opacity: .55; cursor: not-allowed; }
.btn.plain { background: #fff; border-color: var(--line-2); color: var(--brown); }
.btn.plain:hover { background: #fff7ed; border-color: #d9bfa1; }
.btn.ghost { color: var(--muted); padding: 0 8px; }
.btn.ghost:hover { color: var(--brown); background: #fff7ed; }
.btn.circle {
  width: 32px; height: 32px; padding: 0; border-radius: 50%;
  font-size: 18px; line-height: 1; font-weight: 400;
}
.btn.sm { height: 28px; padding: 0 11px; font-size: 12px; }
.btn[disabled] { opacity: .5; cursor: not-allowed; }

/* ---------- 工具栏 ---------- */
.toolbar {
  display: flex; align-items: center; flex-wrap: wrap; gap: 9px;
  padding: 8px 22px 14px;
  border-bottom: 1px solid var(--line);
}
.toolbar .stats { margin-left: auto; display: flex; flex-wrap: wrap; gap: 7px; }
.chip {
  display: inline-flex; align-items: center; gap: 4px;
  height: 24px; padding: 0 9px; border-radius: 4px;
  background: #fff; border: 1px solid var(--line-2);
  font-size: 12px; color: var(--muted);
}
.chip b { color: var(--ink); font-weight: 600; }
.chip.green { background: var(--green-bg); border-color: var(--green-line); color: #1d9c35; }
.chip.green b { color: #158a2b; }
.chip.brown { background: #fff7ed; border-color: #e8d6bf; color: var(--brown-3); }
.chip.brown b { color: var(--brown-3); }

.search { position: relative; width: 190px; }
.search svg { position: absolute; left: 9px; top: 50%; transform: translateY(-50%); color: #a2917d; }
.search input {
  width: 100%; height: 32px; padding: 0 10px 0 29px;
  border-radius: 4px; border: 1px solid var(--line-2);
  background: #fff; outline: none;
}
.search input:focus { border-color: var(--brown); box-shadow: 0 0 0 2px rgba(184, 137, 85, .12); }
.select, .input {
  height: 32px; padding: 0 9px; border-radius: 4px;
  border: 1px solid var(--line-2); background: #fff; outline: none;
}
.select:focus, .input:focus, textarea:focus {
  border-color: var(--brown); box-shadow: 0 0 0 2px rgba(184, 137, 85, .12);
}
.switch { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; color: var(--muted); user-select: none; cursor: pointer; }
.switch input { display: none; }
.switch .track {
  width: 32px; height: 18px; border-radius: 9px; background: #ded2c2; position: relative;
  transition: background .15s;
}
.switch .track::after {
  content: ""; position: absolute; top: 2px; left: 2px; width: 14px; height: 14px; border-radius: 50%;
  background: #fff; box-shadow: 0 1px 2px rgba(0, 0, 0, .18); transition: transform .15s;
}
.switch input:checked + .track { background: var(--brown); }
.switch input:checked + .track::after { transform: translateX(14px); }

/* ---------- 表格 ---------- */
.table-wrap { overflow-x: auto; }
.tbl { width: 100%; border-collapse: collapse; table-layout: fixed; }
.tbl th {
  height: 42px; padding: 0 8px; text-align: center;
  background: var(--thead); color: var(--ink);
  font-size: 13px; font-weight: 600; white-space: nowrap;
  border-bottom: 1px solid var(--line);
}
.tbl td {
  padding: 10px 8px; text-align: center; font-size: 13px;
  border-bottom: 1px solid var(--line);
  color: var(--ink-2); vertical-align: middle;
}
.tbl tbody tr:hover { background: #fffaf3; }
.tbl td.left, .tbl th.left { text-align: left; }
.tbl .idx { color: var(--muted-2); font-variant-numeric: tabular-nums; }
.tbl .name { text-align: left; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tbl .name strong { font-weight: 600; color: var(--ink); }
.tbl .name span { display: block; font-size: 11.5px; color: var(--muted-2); margin-top: 2px; overflow: hidden; text-overflow: ellipsis; }
.tbl .url {
  text-align: left; font-size: 12px; color: var(--muted);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.tbl .url .copy {
  margin-left: 4px; border: 0; background: transparent; color: var(--brown);
  font-size: 11.5px; padding: 0 2px;
}
.tbl .url .copy:hover { text-decoration: underline; }
.tbl .time { font-size: 12px; color: var(--muted-2); font-variant-numeric: tabular-nums; }
.tbl .op { color: var(--brown); cursor: pointer; font-size: 12.5px; user-select: none; }
.tbl .op:hover { text-decoration: underline; }
.tbl tr.expanded { background: #fffaf3; }
.tbl tr.subrow > td { padding: 0; background: #fffaf6; border-bottom: 1px solid var(--line); }
.subtbl { width: 100%; border-collapse: collapse; }
.subtbl th {
  height: 32px; background: #f8efe3; font-size: 12px; font-weight: 600;
  color: var(--muted); border-bottom: 1px solid var(--line);
}
.subtbl td { padding: 8px; font-size: 12px; border-bottom: 1px dashed rgba(176, 146, 109, .18); }
.subtbl tr:last-child td { border-bottom: 0; }
.subtbl .url { text-align: left; }
.subtbl .num { font-variant-numeric: tabular-nums; }
.subtbl .num b { color: var(--ink); }
.subtbl .muted { color: var(--muted-2); }

.progress { display: flex; align-items: center; gap: 8px; justify-content: center; }
.progress .bar { width: 96px; height: 6px; border-radius: 4px; background: #f0e3d2; overflow: hidden; }
.progress .bar i { display: block; height: 100%; width: 0; background: var(--brown); border-radius: 4px; transition: width .35s; }
.progress.done .bar i { background: var(--green); }
.progress span { font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; min-width: 64px; text-align: left; }

.badge {
  display: inline-flex; align-items: center; gap: 4px;
  height: 22px; padding: 0 8px; border-radius: 11px; font-size: 12px;
  background: #f3ece3; color: var(--muted);
}
.badge::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.badge.pending { background: #f4f0ea; color: #94836f; }
.badge.processing { background: #fff3e2; color: #d7821f; }
.badge.done { background: var(--green-bg); color: #1d9c35; }
.badge.failed { background: #fdecec; color: var(--red); }
.err-tip {
  max-width: 150px; margin: 3px auto 0; font-size: 11px; color: var(--red);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}

.empty { padding: 60px 0 70px; text-align: center; color: var(--muted-2); }
.empty-ico { font-size: 40px; color: #ddc9b2; line-height: 1; margin-bottom: 8px; }
.empty p { margin: 0 0 6px; color: var(--muted); font-size: 14px; }
.empty span { font-size: 12px; color: var(--muted-2); }

.pager { display: flex; align-items: center; justify-content: flex-end; gap: 8px; padding: 13px 22px; }
.pager-info { margin-right: 4px; font-size: 12px; color: var(--muted-2); }
.page-now { min-width: 26px; height: 28px; line-height: 28px; text-align: center; font-size: 12px; color: var(--brown); background: #fff7ed; border: 1px solid #e8d6bf; border-radius: 4px; }

/* ---------- 弹窗 ---------- */
.modal-mask {
  position: fixed; inset: 0; z-index: 100;
  background: rgba(22, 19, 16, .45);
  display: flex; align-items: center; justify-content: center;
  padding: 24px;
  animation: fadeIn .15s ease;
}
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
.dialog {
  width: 560px; max-width: 100%; max-height: 90vh; overflow: auto;
  background: var(--card); border: 1px solid var(--line);
  border-radius: 10px; box-shadow: 0 18px 50px rgba(22, 19, 16, .28);
  animation: pop .16s ease;
}
.dialog.narrow { width: 420px; }
@keyframes pop { from { transform: translateY(8px) scale(.985); opacity: .6; } to { transform: none; opacity: 1; } }
.dialog-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 15px 20px; border-bottom: 1px solid var(--line);
  background: #fff8ef;
}
.dialog-head strong { font-size: 15px; font-weight: 600; }
.dialog-close {
  border: 0; background: transparent; font-size: 20px; line-height: 1;
  color: var(--muted-2); padding: 0 2px;
}
.dialog-close:hover { color: var(--ink); }
.dialog-body { padding: 18px 20px 14px; }
.dialog-foot {
  display: flex; justify-content: flex-end; gap: 9px;
  padding: 12px 20px 16px; border-top: 1px solid var(--line);
}
.field { display: block; margin-bottom: 14px; }
.field .label { display: block; font-size: 12.5px; color: var(--muted); margin-bottom: 6px; }
.field .req { color: var(--red); font-style: normal; }
.field textarea, .field .input, .field .select { width: 100%; }
.field textarea {
  min-height: 96px; padding: 9px 10px; border-radius: 4px;
  border: 1px solid var(--line-2); background: #fff; resize: vertical; line-height: 1.55; outline: none;
}
.field .hint { display: block; margin-top: 6px; font-size: 11.5px; color: var(--muted-2); }
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.inline { display: flex; gap: 8px; }
.inline .select { width: 118px; flex: 0 0 auto; }
.inline .input { flex: 1; min-width: 0; }
.quick { display: flex; gap: 6px; margin-top: 7px; }
.quick button {
  height: 22px; padding: 0 8px; border-radius: 11px;
  border: 1px solid var(--line-2); background: #fff; color: var(--muted); font-size: 11.5px;
}
.quick button:hover { border-color: var(--brown); color: var(--brown); }
.preview {
  padding: 10px 12px; border-radius: 6px;
  background: #fff7ed; border: 1px dashed #e3cdb2;
  font-size: 12.5px; color: var(--muted);
}
.preview b { color: var(--brown-3); }
.status-list { list-style: none; margin: 0 0 12px; padding: 0; }
.status-list li {
  display: flex; align-items: center; justify-content: space-between;
  padding: 9px 0; border-bottom: 1px dashed var(--line);
  font-size: 13px;
}
.status-list span { color: var(--muted-2); }
.status-list b { font-weight: 500; color: var(--ink); }
.help-list { margin: 0; padding-left: 18px; line-height: 1.9; color: var(--muted); font-size: 13px; }
.help-list b { color: var(--ink); }

/* ---------- Toast ---------- */
.toast-wrap {
  position: fixed; left: 50%; bottom: 34px; transform: translateX(-50%);
  z-index: 200; display: flex; flex-direction: column; gap: 8px; align-items: center;
  pointer-events: none;
}
.toast {
  max-width: 80vw; padding: 9px 16px; border-radius: 6px;
  background: rgba(43, 33, 24, .92); color: #fff; font-size: 13px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, .2);
  animation: toastIn .18s ease;
}
.toast.err { background: rgba(180, 55, 55, .95); }
.toast.ok { background: rgba(36, 130, 68, .95); }
@keyframes toastIn { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

/* ---------- 响应式 ---------- */
@media (max-width: 1100px) {
  .toolbar .stats { margin-left: 0; width: 100%; }
}
@media (max-width: 860px) {
  .sidebar {
    position: fixed; width: 100%; height: 50px; bottom: auto;
    flex-direction: row; align-items: center;
  }
  .logo { width: auto; flex: 0 0 auto; background: transparent; border: 0; padding: 0 12px; }
  .logo-text { display: none; }
  .nav { flex-direction: row; padding: 0 4px; overflow-x: auto; }
  .nav-item { height: 50px; padding: 0 10px; font-size: 13px; white-space: nowrap; }
  .nav-item.active::before { display: none; }
  .sidebar-foot { display: none; }
  .main { margin-left: 0; padding-top: 50px; }
  .navbar { height: 44px; padding: 0 12px; }
  .tagsbar { display: none; }
  .content { padding: 12px 10px 24px; }
  .page-head { padding: 12px 14px 8px; }
  .toolbar { padding: 8px 14px 12px; }
  .search { width: 100%; }
  .tbl th:nth-child(4), .tbl td:nth-child(4),
  .tbl th:nth-child(8), .tbl td:nth-child(8) { display: none; }
  .tbl { min-width: 720px; }
  .dialog { width: 100%; }
  .field-row { grid-template-columns: 1fr; }
}