:root {
  --bg: #0b1017;
  --bg-2: #111926;
  --panel: #141d2b;
  --panel-2: #182333;
  --line: #24324a;
  --line-2: #2f4160;
  --text: #e6ecf5;
  --muted: #8698b4;
  --dim: #62748f;
  --accent: #3d8bfd;
  --accent-2: #2563eb;
  --green: #2fbf71;
  --amber: #e0a83a;
  --red: #ef5b5b;
  --radius: 10px;
  --shadow: 0 10px 30px rgba(0, 0, 0, .35);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: "PingFang SC", "Microsoft YaHei", "Segoe UI", system-ui, sans-serif;
  font-size: 14px;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--accent); text-decoration: none; }
::-webkit-scrollbar { width: 9px; height: 9px; }
::-webkit-scrollbar-thumb { background: #2a3a54; border-radius: 6px; }
::-webkit-scrollbar-track { background: transparent; }

/* ---------- 布局 ---------- */
.layout { display: grid; grid-template-columns: 208px 1fr; height: 100%; }

.sidebar {
  display: flex;
  flex-direction: column;
  background: linear-gradient(180deg, #101825, #0c121c);
  border-right: 1px solid var(--line);
  padding: 16px 12px;
}

.brand { display: flex; align-items: center; gap: 10px; padding: 4px 6px 18px; }
.brand-mark {
  width: 34px; height: 34px; border-radius: 9px;
  display: grid; place-items: center;
  background: linear-gradient(135deg, var(--accent), #7b5cff);
  color: #fff; font-weight: 800; letter-spacing: .5px;
}
.brand-text { display: flex; flex-direction: column; font-weight: 700; line-height: 1.25; }
.brand-text small { font-weight: 400; font-size: 11px; color: var(--dim); }

.nav { display: flex; flex-direction: column; gap: 4px; }
.nav-item {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 12px; border-radius: 9px;
  color: var(--muted); font-weight: 600;
}
.nav-item:hover { background: #16203050; color: var(--text); }
.nav-item.active { background: #17253c; color: #fff; box-shadow: inset 2px 0 0 var(--accent); }
.nav-ico { width: 18px; text-align: center; opacity: .9; }
.nav-item.small { font-size: 13px; font-weight: 500; }

.sidebar-foot { margin-top: auto; display: flex; flex-direction: column; gap: 8px; }
.ver { font-size: 11px; color: #46566f; padding: 0 8px; line-height: 1.6; }

.main { min-width: 0; display: flex; flex-direction: column; height: 100%; overflow: hidden; }

/* ---------- 通用控件 ---------- */
.btn {
  height: 34px; padding: 0 14px;
  display: inline-flex; align-items: center; gap: 6px;
  border: 1px solid transparent; border-radius: 8px;
  background: linear-gradient(180deg, var(--accent), var(--accent-2));
  color: #fff; font-weight: 600; font-size: 13px; cursor: pointer;
  white-space: nowrap; transition: filter .15s, background .15s;
}
.btn:hover { filter: brightness(1.08); }
.btn:disabled { opacity: .5; cursor: not-allowed; filter: none; }
.btn.ghost { background: #0f1725; border-color: var(--line-2); color: var(--muted); }
.btn.ghost:hover { color: var(--text); border-color: #3d5478; }
.btn.green { background: linear-gradient(180deg, #34c77b, #1f9d5c); }
.btn.red { background: linear-gradient(180deg, #f06a6a, #d43f3f); }
.btn.sm { height: 28px; padding: 0 10px; font-size: 12px; border-radius: 7px; }
.btn.icon { padding: 0 9px; }

.input, .select, .textarea {
  width: 100%; height: 34px; padding: 0 10px;
  background: #0c131e; color: var(--text);
  border: 1px solid var(--line); border-radius: 8px;
  outline: none; font-size: 13px; font-family: inherit;
}
.textarea { height: auto; padding: 8px 10px; line-height: 1.6; resize: vertical; }
.input:focus, .select:focus, .textarea:focus { border-color: var(--accent); background: #0d1622; }
.input::placeholder, .textarea::placeholder { color: #4d5f78; }
.select { cursor: pointer; appearance: none; background-image: linear-gradient(45deg, transparent 50%, #6b7f9c 50%), linear-gradient(135deg, #6b7f9c 50%, transparent 50%); background-position: calc(100% - 15px) 15px, calc(100% - 10px) 15px; background-size: 5px 5px, 5px 5px; background-repeat: no-repeat; padding-right: 26px; }
.mono { font-family: "JetBrains Mono", Consolas, "Courier New", monospace; font-size: 12px; }

label.lbl { display: block; font-size: 12px; color: var(--muted); margin: 0 0 5px; font-weight: 600; }
.hint-text { font-size: 11px; color: var(--dim); line-height: 1.6; margin-top: 5px; }

.check { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; color: var(--muted); cursor: pointer; user-select: none; }
.check input { accent-color: var(--accent); width: 14px; height: 14px; }

.chips { display: inline-flex; background: #0c131e; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; }
.chips button {
  height: 32px; padding: 0 13px; border: 0; background: transparent;
  color: var(--muted); font-weight: 600; font-size: 13px; cursor: pointer;
}
.chips button + button { border-left: 1px solid var(--line); }
.chips button.active { background: linear-gradient(180deg, var(--accent), var(--accent-2)); color: #fff; }

.badge {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 2px 8px; border-radius: 20px; font-size: 11px; font-weight: 600;
  background: #1b2941; color: var(--muted); border: 1px solid var(--line);
}
.badge.ok { color: #7ee2ac; border-color: #2a5a41; background: #14301f; }
.badge.warn { color: #f0c778; border-color: #5a4a24; background: #2e2513; }
.badge.err { color: #ff9a9a; border-color: #5e2e2e; background: #2f1717; }
.badge.run { color: #92c2ff; border-color: #2a4670; background: #142440; }

/* ---------- 顶栏 ---------- */
.topbar {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  padding: 12px 16px; background: var(--bg-2);
  border-bottom: 1px solid var(--line); flex: 0 0 auto;
}
.topbar .grow { flex: 1; min-width: 0; }
.page-title { font-size: 15px; font-weight: 700; white-space: nowrap; }
.page-title small { display: block; font-size: 11px; color: var(--dim); font-weight: 400; }

/* ---------- 面板 ---------- */
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.panel + .panel { margin-top: 12px; }
.panel-hd {
  display: flex; align-items: center; gap: 8px;
  padding: 10px 14px; background: var(--panel-2);
  border-bottom: 1px solid var(--line); font-weight: 700; font-size: 13px;
}
.panel-hd .grow { flex: 1; }
.panel-bd { padding: 14px; }
.panel-bd.tight { padding: 10px; }

.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.grid3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.grid4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; }
.row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.stack { display: flex; flex-direction: column; gap: 10px; }

/* ---------- 蜘蛛浏览页 ---------- */
.proxy-shell { display: flex; flex-direction: column; height: 100%; min-height: 0; }
.proxy-view { flex: 1; min-height: 0; background: #fff; position: relative; }
.proxy-view iframe { width: 100%; height: 100%; border: 0; display: block; }
.proxy-empty {
  position: absolute; inset: 0; display: grid; place-items: center;
  background: var(--bg); color: var(--muted); text-align: center; padding: 24px;
}
.proxy-empty h2 { color: var(--text); margin: 0 0 8px; font-size: 18px; }
.proxy-empty p { margin: 4px 0; font-size: 13px; line-height: 1.8; }
.statusbar {
  display: flex; align-items: center; gap: 14px; flex-wrap: wrap;
  padding: 7px 16px; background: var(--bg-2); border-top: 1px solid var(--line);
  font-size: 12px; color: var(--muted);
}
.statusbar b { color: #9ec1ff; font-weight: 600; }

.source-wrap { position: absolute; inset: 0; background: #0c1220; display: none; flex-direction: column; }
.source-wrap.show { display: flex; }
.source-wrap pre {
  margin: 0; flex: 1; overflow: auto; padding: 14px;
  font-family: Consolas, "Courier New", monospace; font-size: 12px; line-height: 1.65;
  color: #b9cbe4; white-space: pre-wrap; word-break: break-all;
}

/* ---------- 采集页 ---------- */
.collect-body { flex: 1; min-height: 0; display: grid; grid-template-columns: minmax(380px, 30%) 1fr; }
.col-left { overflow: auto; padding: 12px; border-right: 1px solid var(--line); }
.col-right { overflow: hidden; display: flex; flex-direction: column; min-width: 0; }

.field-card { border: 1px solid var(--line); border-radius: 9px; background: var(--panel-2); margin-bottom: 10px; }
.field-hd { display: flex; align-items: center; gap: 8px; padding: 8px 10px; border-bottom: 1px solid var(--line); }
.field-hd .fname { flex: 1; width: auto; min-width: 0; height: 30px; font-weight: 600; }
.field-bd { padding: 10px; display: flex; flex-direction: column; gap: 8px; }
.field-bd.collapsed { display: none; }
.drag-handle { cursor: grab; color: var(--dim); padding: 0 2px; }
.field-card.dragging { opacity: .45; }

.tabs { display: flex; gap: 2px; padding: 0 12px; background: var(--bg-2); border-bottom: 1px solid var(--line); flex: 0 0 auto; }
.tab {
  padding: 10px 14px; font-size: 13px; font-weight: 600; color: var(--muted);
  border: 0; background: transparent; cursor: pointer; border-bottom: 2px solid transparent;
}
.tab.active { color: #fff; border-bottom-color: var(--accent); }
.tab .cnt { color: var(--dim); font-weight: 500; }
.tab-panes { flex: 1; min-height: 0; position: relative; }
.tab-pane { position: absolute; inset: 0; overflow: auto; padding: 12px; display: none; }
.tab-pane.active { display: block; }

.progress { height: 6px; background: #16202f; border-radius: 4px; overflow: hidden; }
.progress > i { display: block; height: 100%; width: 0; background: linear-gradient(90deg, var(--accent), #6ad0ff); transition: width .3s; }

.stats { display: flex; gap: 16px; flex-wrap: wrap; font-size: 12px; color: var(--muted); }
.stats b { color: var(--text); font-size: 15px; display: block; font-weight: 700; }

table.data { width: 100%; border-collapse: collapse; font-size: 12px; }
table.data th, table.data td {
  border: 1px solid var(--line); padding: 6px 8px; text-align: left; vertical-align: top;
}
table.data th { background: var(--panel-2); position: sticky; top: 0; color: var(--muted); white-space: nowrap; z-index: 2; }
table.data td { max-width: 340px; }
table.data td .cell { max-height: 76px; overflow: hidden; white-space: pre-wrap; word-break: break-word; line-height: 1.55; }
table.data tr:hover td { background: #16202fb0; }
.table-scroll { height: 100%; overflow: auto; }

.logbox { font-family: Consolas, monospace; font-size: 12px; line-height: 1.75; }
.logline { display: flex; gap: 8px; padding: 1px 0; border-bottom: 1px solid #16202f60; }
.logline .t { color: #4c5f7a; flex: 0 0 auto; }
.logline .m { color: #a9bcd6; word-break: break-all; }
.logline.warn .m { color: #edc678; }
.logline.error .m { color: #ff9a9a; }

.empty { padding: 40px 20px; text-align: center; color: var(--dim); font-size: 13px; line-height: 1.9; }

/* ---------- 弹层 / 提示 ---------- */
.modal-mask {
  position: fixed; inset: 0; background: #05080dcc; backdrop-filter: blur(2px);
  display: none; place-items: center; z-index: 60; padding: 20px;
}
.modal-mask.show { display: grid; }
.modal { width: min(680px, 100%); max-height: 84vh; display: flex; flex-direction: column; background: var(--panel); border: 1px solid var(--line-2); border-radius: 12px; box-shadow: var(--shadow); }
.modal-hd { display: flex; align-items: center; padding: 12px 16px; border-bottom: 1px solid var(--line); font-weight: 700; }
.modal-bd { padding: 16px; overflow: auto; }
.modal-ft { display: flex; justify-content: flex-end; gap: 8px; padding: 12px 16px; border-top: 1px solid var(--line); }
.close-x { margin-left: auto; cursor: pointer; color: var(--muted); font-size: 18px; line-height: 1; }

.toast-wrap { position: fixed; top: 16px; left: 50%; transform: translateX(-50%); z-index: 99; display: flex; flex-direction: column; gap: 8px; align-items: center; }
.toast {
  padding: 9px 16px; border-radius: 8px; font-size: 13px; font-weight: 600;
  background: #1c2a41; border: 1px solid var(--line-2); color: var(--text);
  box-shadow: var(--shadow); animation: drop .25s ease;
}
.toast.ok { border-color: #2a5a41; color: #90e9b8; }
.toast.err { border-color: #6a2f2f; color: #ffa9a9; }
@keyframes drop { from { opacity: 0; transform: translateY(-8px); } }

.rule-list { display: flex; flex-direction: column; gap: 6px; }
.rule-row { display: flex; align-items: center; gap: 10px; padding: 9px 12px; border: 1px solid var(--line); border-radius: 8px; background: var(--panel-2); }
.rule-row .nm { flex: 1; font-weight: 600; }
.rule-row .tm { font-size: 11px; color: var(--dim); }

/* ---------- 登录 ---------- */
.login-wrap { display: grid; place-items: center; height: 100%; background: radial-gradient(1000px 500px at 50% -10%, #17263f, var(--bg)); }
.login-card { width: 340px; padding: 28px; background: var(--panel); border: 1px solid var(--line); border-radius: 14px; box-shadow: var(--shadow); }
.login-card h1 { margin: 0 0 4px; font-size: 20px; }
.login-card p { margin: 0 0 18px; color: var(--dim); font-size: 12px; }
.login-card .btn { width: 100%; justify-content: center; margin-top: 12px; height: 38px; }
.login-err { color: #ff9a9a; font-size: 12px; margin-top: 10px; }

@media (max-width: 1100px) {
  .collect-body { grid-template-columns: 1fr; }
  .col-left { border-right: 0; border-bottom: 1px solid var(--line); max-height: 55vh; }
}
@media (max-width: 720px) {
  .layout { grid-template-columns: 62px 1fr; }
  .brand-text, .nav-item span:not(.nav-ico), .ver { display: none; }
  .nav-item { justify-content: center; }
}
