/* ============================================================
   MergeProxy · Clash / sing-box 配置合并器
   ============================================================ */

:root {
  --bg: #f4f5f8;
  --surface: #ffffff;
  --surface-2: #fafbfc;
  --line: #e6e8ee;
  --line-strong: #d6d9e2;
  --text: #15181f;
  --text-2: #444b58;
  --muted: #7a8291;
  --brand: #4f46e5;
  --brand-2: #6366f1;
  --brand-soft: #eef0ff;
  --green: #0e9f6e;
  --green-soft: #e6f7f1;
  --amber: #b45309;
  --amber-soft: #fdf3e3;
  --red: #dc2626;
  --red-soft: #fdecec;
  --radius: 14px;
  --radius-sm: 9px;
  --shadow-sm: 0 1px 2px rgba(16, 24, 40, .05);
  --shadow: 0 1px 3px rgba(16, 24, 40, .06), 0 8px 24px -12px rgba(16, 24, 40, .12);
  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, "Liberation Mono", monospace;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
    "Hiragino Sans GB", "Microsoft YaHei", Roboto, Helvetica, Arial, sans-serif;
  font-size: 14px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3, h4, p { margin: 0; }
button, input, select, textarea { font-family: inherit; font-size: inherit; color: inherit; }
button { cursor: pointer; }
svg { width: 16px; height: 16px; flex: none; }

/* ---------------- 顶栏 ---------------- */

.topbar {
  position: sticky;
  top: 0;
  z-index: 50;
  display: flex;
  align-items: center;
  gap: 22px;
  height: 66px;
  padding: 0 24px;
  background: rgba(255, 255, 255, .88);
  backdrop-filter: saturate(180%) blur(12px);
  border-bottom: 1px solid var(--line);
}

.brand { display: flex; align-items: center; gap: 11px; flex: none; }

.logo {
  width: 36px; height: 36px;
  display: grid; place-items: center;
  border-radius: 11px;
  background: linear-gradient(140deg, #6366f1, #4338ca);
  color: #fff;
  box-shadow: 0 4px 12px -4px rgba(79, 70, 229, .6);
}
.logo svg { width: 20px; height: 20px; }

.brand-text h1 { font-size: 15px; font-weight: 650; letter-spacing: -.01em; }
.brand-text p { font-size: 11.5px; color: var(--muted); letter-spacing: .01em; }

.tabs {
  display: flex;
  gap: 2px;
  padding: 3px;
  background: #eff0f4;
  border-radius: 10px;
}
.tab {
  border: 0;
  background: transparent;
  padding: 6px 15px;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-2);
  transition: .15s;
}
.tab:hover { color: var(--text); }
.tab.active {
  background: #fff;
  color: var(--brand);
  font-weight: 600;
  box-shadow: var(--shadow-sm);
}

.stats { margin-left: auto; display: flex; gap: 8px; }
.stat-chip {
  display: flex; align-items: baseline; gap: 5px;
  padding: 5px 11px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #fff;
  font-size: 12px;
  color: var(--muted);
}
.stat-chip b { color: var(--text); font-size: 13px; font-variant-numeric: tabular-nums; }

/* ---------------- 布局 ---------------- */

main { max-width: 1280px; margin: 0 auto; padding: 22px 24px 64px; }

.view { display: none; animation: fade .22s ease; }
.view.active { display: block; }
@keyframes fade { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }

.panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
}

.toolbar {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 13px 15px;
  margin-bottom: 14px;
  flex-wrap: wrap;
}
.spacer { flex: 1; }
.pad { padding: 20px; }

.section-title { min-width: 0; }
.section-title h2 { font-size: 15px; font-weight: 650; }
.section-title p { font-size: 12.5px; color: var(--muted); margin-top: 2px; }

/* ---------------- 控件 ---------------- */

.search {
  display: flex; align-items: center; gap: 8px;
  padding: 0 11px;
  height: 36px;
  min-width: 240px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  transition: .15s;
}
.search:focus-within { border-color: var(--brand-2); background: #fff; box-shadow: 0 0 0 3px rgba(99, 102, 241, .12); }
.search svg { width: 15px; height: 15px; color: var(--muted); }
.search input { border: 0; outline: 0; background: transparent; width: 100%; }

input[type="text"], input:not([type]), .select, textarea {
  width: 100%;
  height: 36px;
  padding: 0 11px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  outline: 0;
  transition: .15s;
}
textarea {
  height: auto;
  padding: 10px 12px;
  resize: vertical;
  line-height: 1.6;
  font-family: var(--mono);
  font-size: 12.5px;
}
input:focus, .select:focus, textarea:focus {
  border-color: var(--brand-2);
  background: #fff;
  box-shadow: 0 0 0 3px rgba(99, 102, 241, .12);
}
.select {
  appearance: none;
  padding-right: 30px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%237a8291' stroke-width='2.5' stroke-linecap='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
  cursor: pointer;
}
.select.sm { width: auto; min-width: 120px; height: 36px; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  height: 36px;
  padding: 0 14px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--line-strong);
  background: #fff;
  color: var(--text-2);
  font-size: 13px;
  font-weight: 500;
  white-space: nowrap;
  text-decoration: none;
  transition: .15s;
}
.btn:hover { background: var(--surface-2); border-color: #c3c7d2; color: var(--text); }
.btn:active { transform: translateY(.5px); }
.btn:disabled { opacity: .45; cursor: not-allowed; transform: none; }
.btn svg { width: 15px; height: 15px; }

.btn.primary {
  background: linear-gradient(180deg, #5b53ea, #4a41d8);
  border-color: #453ccf;
  color: #fff;
  box-shadow: 0 2px 6px -1px rgba(79, 70, 229, .4);
}
.btn.primary:hover { background: linear-gradient(180deg, #655df0, #4f46e5); color: #fff; }
.btn.ghost { background: #fff; }
.btn.sm { height: 32px; padding: 0 11px; font-size: 12.5px; }
.btn.lg { height: 42px; font-size: 14px; font-weight: 600; }
.btn.block { width: 100%; }
.btn.danger-text { color: var(--red); }
.btn.danger-text:hover { background: var(--red-soft); border-color: #f3b9b9; }

.link-btn {
  border: 0; background: transparent; padding: 2px 4px;
  color: var(--brand); font-size: 12.5px; font-weight: 500;
  border-radius: 5px;
}
.link-btn:hover { background: var(--brand-soft); }

.icon-btn {
  width: 30px; height: 30px;
  display: grid; place-items: center;
  border: 1px solid transparent;
  border-radius: 8px;
  background: transparent;
  color: var(--muted);
  transition: .15s;
}
.icon-btn:hover { background: #f1f2f6; color: var(--text); border-color: var(--line); }
.icon-btn.danger:hover { background: var(--red-soft); color: var(--red); border-color: #f5c2c2; }

/* ---------------- 节点列表 ---------------- */

.list-panel { overflow: hidden; }

.node-grid {
  display: grid;
  grid-template-columns: 34px minmax(140px, 1.5fr) 96px minmax(140px, 1.2fr) 92px 96px;
  align-items: center;
  gap: 10px;
  padding: 0 16px;
}

.list-head {
  height: 40px;
  background: var(--surface-2);
  border-bottom: 1px solid var(--line);
  font-size: 11.5px;
  font-weight: 600;
  letter-spacing: .04em;
  text-transform: uppercase;
  color: var(--muted);
}
.list-head .right { text-align: right; }

.node-row {
  min-height: 52px;
  border-bottom: 1px solid #f0f1f5;
  transition: background .12s;
}
.node-row:last-child { border-bottom: 0; }
.node-row:hover { background: #fbfbfd; }
.node-row.selected { background: #f7f7ff; }

.node-name {
  font-weight: 550;
  font-size: 13.5px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.node-sub {
  font-size: 11.5px;
  color: var(--muted);
  font-family: var(--mono);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.node-addr { font-family: var(--mono); font-size: 12.5px; color: var(--text-2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.node-actions { display: flex; gap: 2px; justify-content: flex-end; }

.cb { display: inline-flex; cursor: pointer; }
.cb input { display: none; }
.cb span {
  width: 16px; height: 16px;
  border: 1.5px solid var(--line-strong);
  border-radius: 5px;
  background: #fff;
  display: block;
  position: relative;
  transition: .12s;
}
.cb input:checked + span { background: var(--brand); border-color: var(--brand); }
.cb input:checked + span::after {
  content: "";
  position: absolute;
  left: 4.5px; top: 1.5px;
  width: 4px; height: 8px;
  border: solid #fff;
  border-width: 0 2px 2px 0;
  transform: rotate(42deg);
}
.cb input:indeterminate + span { background: var(--brand); border-color: var(--brand); }
.cb input:indeterminate + span::after {
  content: "";
  position: absolute;
  left: 3.5px; top: 7px;
  width: 8px; height: 2px;
  border-radius: 1px;
  background: #fff;
}

.badge {
  display: inline-flex; align-items: center;
  height: 21px;
  padding: 0 8px;
  border-radius: 6px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: .01em;
  text-transform: uppercase;
  background: #f1f2f6;
  color: #4b5262;
  white-space: nowrap;
}
.badge.vmess { background: #eef0ff; color: #4338ca; }
.badge.vless { background: #e7f0ff; color: #1d4ed8; }
.badge.trojan { background: #f6ecff; color: #7c3aed; }
.badge.ss { background: #e4f7f2; color: #0f766e; }
.badge.ssr { background: #e4f7f2; color: #0f766e; }
.badge.hysteria2, .badge.hysteria { background: #ffe9f2; color: #be185d; }
.badge.tuic { background: #fff0e2; color: #b45309; }
.badge.socks5, .badge.http { background: #eef1f5; color: #475569; }
.badge.anytls { background: #eaf6ff; color: #0369a1; }

.src-tag {
  font-size: 11.5px;
  color: var(--muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* 空状态 */
.empty {
  padding: 56px 24px;
  text-align: center;
  color: var(--muted);
}
.empty .empty-icon {
  width: 52px; height: 52px;
  margin: 0 auto 14px;
  display: grid; place-items: center;
  border-radius: 14px;
  background: var(--brand-soft);
  color: var(--brand);
}
.empty .empty-icon svg { width: 24px; height: 24px; }
.empty h3 { font-size: 14px; color: var(--text); margin-bottom: 4px; }
.empty p { font-size: 12.5px; margin-bottom: 16px; }

/* ---------------- 模板卡片 ---------------- */

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 14px;
}

.tpl-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  transition: .16s;
  box-shadow: var(--shadow-sm);
}
.tpl-card:hover { border-color: #cfd3de; box-shadow: var(--shadow); transform: translateY(-1px); }

.tpl-top { display: flex; align-items: flex-start; gap: 10px; }
.tpl-icon {
  width: 34px; height: 34px;
  border-radius: 9px;
  display: grid; place-items: center;
  background: var(--brand-soft);
  color: var(--brand);
  flex: none;
}
.tpl-icon.singbox { background: #e9f7ef; color: #0e9f6e; }
.tpl-name { font-weight: 600; font-size: 14px; word-break: break-all; }
.tpl-meta { font-size: 11.5px; color: var(--muted); margin-top: 1px; }
.tpl-preview {
  font-family: var(--mono);
  font-size: 11px;
  line-height: 1.6;
  color: #7c8494;
  background: var(--surface-2);
  border: 1px solid #eef0f4;
  border-radius: 8px;
  padding: 8px 10px;
  height: 62px;
  overflow: hidden;
  white-space: pre;
  position: relative;
  mask-image: linear-gradient(#000 60%, transparent);
}
.tpl-actions { display: flex; gap: 6px; margin-top: auto; }

/* ---------------- 订阅页 ---------------- */

.sub-layout {
  display: grid;
  grid-template-columns: minmax(0, 1.05fr) minmax(0, 1fr);
  gap: 16px;
  align-items: start;
}

.form-panel { padding: 20px; display: flex; flex-direction: column; gap: 14px; }
.form-panel > .section-title { margin-bottom: 2px; }

.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.field > label { font-size: 12.5px; font-weight: 550; color: var(--text-2); }
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }

.picker-head { display: flex; align-items: center; justify-content: space-between; }
.picker-actions { display: flex; gap: 2px; }
.counter { font-size: 11.5px; color: var(--muted); font-weight: 400; margin-left: 4px; }

.picker {
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
  overflow: hidden;
  background: var(--surface-2);
}
.picker-search { padding: 8px; border-bottom: 1px solid var(--line); background: #fff; }
.picker-search input { height: 30px; font-size: 12.5px; }
.picker-list { max-height: 260px; overflow-y: auto; padding: 4px; }

.pick-item {
  display: flex; align-items: center; gap: 9px;
  padding: 7px 8px;
  border-radius: 7px;
  cursor: pointer;
  transition: background .12s;
}
.pick-item:hover { background: #f2f3f8; }
.pick-item.checked { background: var(--brand-soft); }
.pick-item .pick-name { flex: 1; min-width: 0; font-size: 12.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pick-item .pick-addr { font-size: 11px; color: var(--muted); font-family: var(--mono); }

.pick-group { border-bottom: 1px solid var(--line); }
.pick-group:last-child { border-bottom: 0; }
.pick-group-head {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 8px;
  border-radius: 7px;
  background: #f7f8fb;
}
.pick-group.all .pick-group-head { background: var(--brand-soft); }
.pick-group.some .pick-group-head { background: #fbfbff; }
.pick-group-name {
  flex: 1;
  min-width: 0;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-2);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.pick-group-count { font-size: 11px; color: var(--muted); font-family: var(--mono); }
.pick-toggle {
  width: 22px;
  height: 22px;
  padding: 0;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--muted);
  display: grid;
  place-items: center;
  cursor: pointer;
}
.pick-toggle:hover { background: #eef0f6; color: var(--text); }
.pick-toggle svg { width: 13px; height: 13px; transition: transform .15s; transform: rotate(90deg); }
.pick-group.collapsed .pick-toggle svg { transform: rotate(0deg); }
.pick-group-body { padding: 2px 0 4px; }
.pick-group.collapsed .pick-group-body { display: none; }
.pick-group-body .pick-item { margin-left: 20px; }

.checkline { display: flex; align-items: flex-start; gap: 9px; font-size: 12.5px; color: var(--text-2); cursor: pointer; }
.checkline input { margin: 2px 0 0; accent-color: var(--brand); width: 15px; height: 15px; }

.sub-list { display: flex; flex-direction: column; gap: 12px; margin-top: 16px; }

.sub-card {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px;
  background: var(--surface);
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.sub-card:hover { border-color: #d3d7e1; }
.sub-card-top { display: flex; align-items: center; gap: 9px; }
.sub-card-name { font-weight: 600; font-size: 13.5px; flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sub-card-meta { font-size: 11.5px; color: var(--muted); display: flex; gap: 10px; flex-wrap: wrap; }

.url-box {
  display: flex;
  align-items: center;
  gap: 6px;
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 5px 5px 5px 10px;
}
.url-box code {
  flex: 1;
  min-width: 0;
  font-family: var(--mono);
  font-size: 11.5px;
  color: var(--text-2);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.tag {
  font-size: 10.5px;
  padding: 1px 7px;
  border-radius: 999px;
  background: var(--brand-soft);
  color: var(--brand);
  font-weight: 600;
}
.tag.gray { background: #f1f2f6; color: var(--muted); }
.tag.green { background: var(--green-soft); color: var(--green); }

/* ---------------- 弹窗 ---------------- */

.modal-mask {
  position: fixed; inset: 0;
  background: rgba(18, 22, 33, .42);
  backdrop-filter: blur(2px);
  display: flex; align-items: center; justify-content: center;
  padding: 24px;
  z-index: 100;
  animation: fade .16s ease;
}
.modal-mask[hidden] { display: none; }

.modal {
  width: 100%;
  max-width: 620px;
  max-height: 88vh;
  display: flex;
  flex-direction: column;
  background: var(--surface);
  border-radius: 16px;
  box-shadow: 0 24px 64px -16px rgba(16, 24, 40, .35);
  animation: pop .18s cubic-bezier(.2, .8, .3, 1);
}
.modal.wide { max-width: 860px; }
@keyframes pop { from { opacity: 0; transform: translateY(10px) scale(.99); } to { opacity: 1; transform: none; } }

.modal-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 18px;
  border-bottom: 1px solid var(--line);
}
.modal-head h3 { font-size: 15px; font-weight: 650; }
.modal-body { padding: 18px; overflow-y: auto; }
.modal-foot {
  display: flex; justify-content: flex-end; gap: 8px;
  padding: 14px 18px;
  border-top: 1px solid var(--line);
  background: var(--surface-2);
  border-radius: 0 0 16px 16px;
}
.modal-foot:empty { display: none; }

/* 弹窗内 tab */
.seg {
  display: flex; gap: 2px; padding: 3px;
  background: #eff0f4; border-radius: 9px; margin-bottom: 16px;
}
.seg button {
  flex: 1; border: 0; background: transparent;
  padding: 7px 10px; border-radius: 7px;
  font-size: 12.5px; font-weight: 500; color: var(--text-2);
}
.seg button.active { background: #fff; color: var(--brand); font-weight: 600; box-shadow: var(--shadow-sm); }

.tab-pane { display: none; }
.tab-pane.active { display: block; }

.hint { font-size: 12px; color: var(--muted); line-height: 1.65; }
.hint code {
  font-family: var(--mono); font-size: 11.5px;
  background: #f2f3f7; padding: 1px 5px; border-radius: 4px; color: var(--text-2);
}

.preview-meta {
  display: flex; align-items: center; gap: 8px;
  margin-top: 10px;
  font-size: 12px;
  color: var(--muted);
}
.preview-list { max-height: 160px; overflow-y: auto; margin-top: 10px; border: 1px solid var(--line); border-radius: 8px; }
.preview-item {
  display: flex; align-items: center; gap: 8px;
  padding: 6px 10px;
  font-size: 12px;
  border-bottom: 1px solid #f2f3f7;
}
.preview-item:last-child { border-bottom: 0; }
.preview-item .addr { color: var(--muted); font-family: var(--mono); font-size: 11px; }

.warn-box {
  margin-top: 10px;
  padding: 9px 11px;
  border-radius: 8px;
  background: var(--amber-soft);
  color: var(--amber);
  font-size: 11.5px;
  line-height: 1.6;
  max-height: 120px;
  overflow-y: auto;
}

.code-view {
  margin: 0;
  padding: 14px;
  background: #12161f;
  color: #d7dce6;
  border-radius: 10px;
  font-family: var(--mono);
  font-size: 11.5px;
  line-height: 1.65;
  overflow: auto;
  max-height: 56vh;
  white-space: pre;
  tab-size: 2;
}
.code-view.light {
  background: var(--surface-2);
  color: var(--text-2);
  border: 1px solid var(--line);
  max-height: 300px;
}

.qr-wrap {
  display: flex; flex-direction: column; align-items: center; gap: 10px;
  padding: 6px 0;
}
.qr-wrap svg, .qr-wrap img { border-radius: 8px; background: #fff; padding: 8px; border: 1px solid var(--line); }
.qr-cap { font-size: 12px; color: var(--muted); text-align: center; word-break: break-all; max-width: 340px; }

video.qr-video {
  width: 100%;
  border-radius: 10px;
  background: #000;
  aspect-ratio: 4 / 3;
  object-fit: cover;
}

/* ---------------- Toast ---------------- */

.toasts {
  position: fixed;
  right: 20px; bottom: 20px;
  display: flex; flex-direction: column; gap: 8px;
  z-index: 200;
}
.toast {
  display: flex; align-items: center; gap: 9px;
  min-width: 200px;
  padding: 10px 14px;
  background: #1b1f2a;
  color: #f2f4f8;
  border-radius: 10px;
  font-size: 12.5px;
  box-shadow: 0 12px 32px -8px rgba(0, 0, 0, .4);
  animation: slideIn .2s ease;
}
.toast.ok { background: #0d2f27; color: #d6f7ea; }
.toast.err { background: #331417; color: #ffdede; }
.toast.out { animation: slideOut .2s ease forwards; }
@keyframes slideIn { from { opacity: 0; transform: translateX(12px); } to { opacity: 1; transform: none; } }
@keyframes slideOut { to { opacity: 0; transform: translateX(12px); } }

/* ---------------- 订阅源 ---------------- */

.sources-panel { margin-bottom: 14px; overflow: hidden; }
.sources-head { display: flex; align-items: center; gap: 9px; padding: 13px 15px; flex-wrap: wrap; }
.sources-head .section-title h2 { display: flex; align-items: center; gap: 6px; }
#source-list:not(:empty) { border-top: 1px solid var(--line); }

.source-group { border-bottom: 1px solid #f2f3f7; }
.source-group:last-child { border-bottom: 0; }

.source-row {
  display: grid;
  grid-template-columns: 24px 32px minmax(0, 1fr) 104px auto;
  align-items: center;
  gap: 11px;
  padding: 9px 15px;
  border-bottom: 0;
  transition: background .12s;
}
.source-group.open .source-row { border-bottom: 1px solid #eef0f4; }
.source-row:hover { background: #fbfbfd; }
.source-row.busy { opacity: .55; pointer-events: none; }

.source-toggle {
  width: 24px;
  height: 24px;
  padding: 0;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--muted);
  display: grid;
  place-items: center;
  cursor: pointer;
}
.source-toggle:hover { background: #f1f2f6; color: var(--text); }
.source-toggle svg { width: 14px; height: 14px; transition: transform .15s; }
.source-group.open .source-toggle svg { transform: rotate(90deg); }

.source-nodes {
  background: #fafbfd;
  box-shadow: inset 2px 0 0 #eef0ff;
}
.source-nodes .node-row:last-child { border-bottom: 0; }
.source-nodes-empty {
  padding: 14px 16px 14px 72px;
  color: var(--muted);
  font-size: 12px;
}

.node-grid-inner {
  display: grid;
  grid-template-columns: 34px minmax(140px, 1.5fr) 96px minmax(140px, 1.2fr) 96px;
  align-items: center;
  gap: 10px;
  padding: 0 16px 0 72px;
}

.source-icon {
  width: 30px; height: 30px;
  border-radius: 8px;
  display: grid; place-items: center;
  background: var(--brand-soft);
  color: var(--brand);
  flex: none;
}
.source-icon svg { width: 15px; height: 15px; }
.source-icon.err { background: var(--red-soft); color: var(--red); }

.source-main { min-width: 0; }
.source-name { display: flex; align-items: center; gap: 6px; font-size: 13px; font-weight: 550; }
.source-name .nm { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.source-url {
  font-family: var(--mono);
  font-size: 11px;
  color: var(--muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  margin-top: 1px;
}
.source-time { font-size: 11.5px; color: var(--muted); text-align: right; line-height: 1.4; }
.source-time .err { color: var(--red); }
.source-actions { display: flex; gap: 2px; }
.source-empty { padding: 18px 15px; text-align: center; color: var(--muted); font-size: 12.5px; }

.tag.red { background: var(--red-soft); color: var(--red); }
.tag.amber { background: var(--amber-soft); color: var(--amber); }

@keyframes spin { to { transform: rotate(360deg); } }
.spin { animation: spin .9s linear infinite; }

/* ---------------- 响应式 ---------------- */

@media (max-width: 1000px) {
  .sub-layout { grid-template-columns: 1fr; }
  .stats { display: none; }
}
@media (max-width: 760px) {
  main { padding: 16px 14px 56px; }
  .topbar { height: auto; flex-wrap: wrap; gap: 12px; padding: 12px 14px; }
  .tabs { order: 3; width: 100%; }
  .tab { flex: 1; }
  .node-grid { grid-template-columns: 30px 1fr 78px 76px; }
  .node-grid > :nth-child(4), .node-grid > :nth-child(5) { display: none; }
  .source-row { grid-template-columns: 22px 30px minmax(0, 1fr) auto; }
  .source-time { display: none; }
  .node-grid-inner { grid-template-columns: 30px minmax(0, 1fr) 78px 76px; padding-left: 44px; }
  .node-grid-inner > :nth-child(4) { display: none; }
  .source-nodes-empty { padding-left: 44px; }
  .field-row { grid-template-columns: 1fr; }
  .toolbar { gap: 7px; }
  .search { min-width: 0; flex: 1; }
}

/* ---------------- 登录 ---------------- */

.login-overlay {
  position: fixed; inset: 0; z-index: 2000;
  display: flex; align-items: center; justify-content: center;
  background: linear-gradient(160deg, #eef0ff 0%, #f4f5f8 55%, #ffffff 100%);
}
.login-overlay.hidden { display: none; }

.login-card {
  width: 100%; max-width: 360px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 32px 28px 28px;
  box-shadow: var(--shadow);
}
.login-brand { text-align: center; margin-bottom: 22px; }
.login-brand .logo.lg {
  width: 48px; height: 48px;
  margin: 0 auto 12px;
  color: var(--brand);
}
.login-brand h1 { font-size: 20px; font-weight: 700; margin: 0; color: var(--text); }
.login-brand p { font-size: 13px; color: var(--muted); margin: 4px 0 0; }

.login-card .field { margin-bottom: 14px; }
.login-card input[type="password"] {
  width: 100%; padding: 11px 14px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
  font-size: 14px;
  background: var(--surface-2);
  transition: border-color .15s, box-shadow .15s;
}
.login-card input[type="password"]:focus {
  outline: none;
  border-color: var(--brand-2);
  box-shadow: 0 0 0 3px var(--brand-soft);
}

.login-card .hint {
  font-size: 12.5px; color: var(--red);
  margin: -6px 0 12px;
  min-height: 18px;
}

.user-menu { display: flex; align-items: center; gap: 6px; }

.source-pick-list {
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  max-height: 180px;
  overflow-y: auto;
}
.source-pick-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  cursor: pointer;
  transition: background .1s;
}
.source-pick-item:hover { background: var(--surface); }
.source-pick-item + .source-pick-item { border-top: 1px solid var(--line); }
.source-pick-item input[type="checkbox"] {
  width: 16px; height: 16px; flex-shrink: 0;
  accent-color: var(--brand);
}
.source-pick-item .nm {
  font-size: 13px; font-weight: 500; color: var(--text);
  flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.source-pick-item .ct {
  font-size: 11.5px; color: var(--muted); flex-shrink: 0;
}
.source-pick-empty {
  padding: 14px; text-align: center; color: var(--muted); font-size: 12.5px;
}

.segmented {
  display: inline-flex;
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 3px;
  gap: 3px;
}
.segmented button {
  padding: 6px 14px;
  border: none;
  border-radius: 6px;
  background: transparent;
  color: var(--text-2);
  font-size: 13px;
  cursor: pointer;
  transition: all .15s;
}
.segmented button.active {
  background: var(--surface);
  color: var(--text);
  box-shadow: var(--shadow-sm);
  font-weight: 500;
}
.segmented button:hover:not(.active) {
  color: var(--text);
}
