:root {
  --bg: #0b0d12;
  --bg-soft: #11141b;
  --card: #161a23;
  --card-2: #1c212c;
  --line: #262c3a;
  --line-soft: #1e2432;
  --txt: #e6eaf2;
  --txt-dim: #9aa4b8;
  --txt-faint: #6b7488;
  --pri: #4f7cff;
  --pri-soft: rgba(79, 124, 255, 0.14);
  --ok: #2ecc8f;
  --warn: #f0b429;
  --err: #ff5c5c;
  --radius: 12px;
  --shadow: 0 12px 40px rgba(0, 0, 0, 0.45);
}

* { box-sizing: border-box; }

html, body { height: 100%; }

body {
  margin: 0;
  background: radial-gradient(1200px 600px at 70% -10%, #1a2233 0%, var(--bg) 55%) no-repeat, var(--bg);
  color: var(--txt);
  font: 14px/1.55 -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB",
    "Microsoft YaHei", sans-serif;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--pri); text-decoration: none; }
a:hover { text-decoration: underline; }

button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }

/* ── 登录 ─────────────────────────────────── */
.login-wrap {
  min-height: 100vh; display: grid; place-items: center; padding: 24px;
}
.login-card {
  width: 100%; max-width: 400px; background: var(--card); border: 1px solid var(--line);
  border-radius: 18px; padding: 36px 32px; box-shadow: var(--shadow);
}
.login-card h1 { margin: 0 0 6px; font-size: 22px; letter-spacing: .3px; }
.login-card p.sub { margin: 0 0 26px; color: var(--txt-dim); font-size: 13px; }
.brand-dot {
  width: 40px; height: 40px; border-radius: 12px; margin-bottom: 18px;
  background: linear-gradient(135deg, var(--pri), #8b5cf6);
  display: grid; place-items: center; font-weight: 800; font-size: 18px; color: #fff;
}

/* ── 表单 ─────────────────────────────────── */
.field { margin-bottom: 16px; }
.field > label {
  display: block; margin-bottom: 7px; font-size: 12.5px; color: var(--txt-dim);
  letter-spacing: .3px; font-weight: 500;
}
.field > label .req { color: var(--err); margin-left: 2px; }
input[type="text"], input[type="password"], input[type="number"], select, textarea {
  width: 100%; background: var(--bg-soft); border: 1px solid var(--line);
  border-radius: 9px; padding: 10px 12px; outline: none; transition: .15s;
  font-size: 13.5px;
}
input:focus, select:focus, textarea:focus {
  border-color: var(--pri); box-shadow: 0 0 0 3px var(--pri-soft); background: #0e1119;
}
textarea { resize: vertical; min-height: 78px; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12.5px; }
select { appearance: none; background-image: linear-gradient(45deg, transparent 50%, var(--txt-faint) 50%), linear-gradient(135deg, var(--txt-faint) 50%, transparent 50%); background-position: calc(100% - 16px) 50%, calc(100% - 11px) 50%; background-size: 5px 5px, 5px 5px; background-repeat: no-repeat; padding-right: 32px; }
.hint { font-size: 12px; color: var(--txt-faint); margin-top: 6px; line-height: 1.5; }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.row3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 14px; }
@media (max-width: 720px) { .row2, .row3 { grid-template-columns: 1fr; } }

/* ── 按钮 ─────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 9px 16px; border-radius: 9px; border: 1px solid var(--line);
  background: var(--card-2); color: var(--txt); font-size: 13.5px; font-weight: 500;
  transition: .15s; white-space: nowrap;
}
.btn:hover { background: #232938; border-color: #333b4d; }
.btn:active { transform: translateY(1px); }
.btn.pri { background: var(--pri); border-color: var(--pri); color: #fff; }
.btn.pri:hover { background: #3f6cf5; }
.btn.danger { color: var(--err); border-color: rgba(255, 92, 92, .35); background: rgba(255, 92, 92, .08); }
.btn.danger:hover { background: rgba(255, 92, 92, .16); }
.btn.sm { padding: 6px 11px; font-size: 12.5px; border-radius: 7px; }
.btn.ghost { background: transparent; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn-block { width: 100%; }

/* ── 布局 ─────────────────────────────────── */
.app-shell { display: grid; grid-template-columns: 224px 1fr; min-height: 100vh; }
@media (max-width: 860px) { .app-shell { grid-template-columns: 1fr; } }

.sidebar {
  background: #0d1017; border-right: 1px solid var(--line-soft);
  padding: 20px 14px; display: flex; flex-direction: column; gap: 6px;
  position: sticky; top: 0; height: 100vh;
}
@media (max-width: 860px) { .sidebar { position: static; height: auto; flex-direction: row; overflow-x: auto; } }

.sb-brand { display: flex; align-items: center; gap: 10px; padding: 4px 8px 18px; }
.sb-brand .dot { width: 30px; height: 30px; border-radius: 9px; background: linear-gradient(135deg, var(--pri), #8b5cf6); display: grid; place-items: center; font-weight: 800; color: #fff; font-size: 14px; }
.sb-brand b { font-size: 14.5px; letter-spacing: .3px; }

.nav-item {
  display: flex; align-items: center; gap: 10px; padding: 10px 12px; border-radius: 9px;
  color: var(--txt-dim); font-size: 13.5px; transition: .15s; cursor: pointer; border: none; background: none; width: 100%; text-align: left;
}
.nav-item:hover { background: #151a24; color: var(--txt); }
.nav-item.active { background: var(--pri-soft); color: #a9c0ff; font-weight: 600; }
.nav-item .ico { font-size: 15px; opacity: .9; }
.sb-spacer { flex: 1; }
.sb-user { border-top: 1px solid var(--line-soft); padding-top: 12px; font-size: 12.5px; color: var(--txt-faint); }
.sb-user .name { color: var(--txt); font-weight: 600; font-size: 13.5px; display: flex; align-items: center; gap: 6px; }

.main { padding: 26px 30px 60px; min-width: 0; }
.page-head { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 20px; flex-wrap: wrap; }
.page-head h2 { margin: 0; font-size: 19px; letter-spacing: .3px; }
.page-head .sub { color: var(--txt-faint); font-size: 12.5px; margin-top: 3px; }

/* ── 卡片/表格 ─────────────────────────────── */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.card + .card { margin-top: 18px; }
.card-head { padding: 15px 18px; border-bottom: 1px solid var(--line-soft); display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.card-head h3 { margin: 0; font-size: 14.5px; }
.card-body { padding: 18px; }

table { width: 100%; border-collapse: collapse; font-size: 13px; }
th {
  text-align: left; padding: 11px 14px; color: var(--txt-faint); font-weight: 500;
  font-size: 12px; letter-spacing: .4px; text-transform: uppercase; border-bottom: 1px solid var(--line-soft);
  background: #14181f; white-space: nowrap;
}
td { padding: 12px 14px; border-bottom: 1px solid var(--line-soft); vertical-align: middle; }
tbody tr:last-child td { border-bottom: none; }
tbody tr:hover { background: #1a1f2a; }
.table-wrap { overflow-x: auto; }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12.5px; }
.muted { color: var(--txt-faint); }
.dim { color: var(--txt-dim); }
.nowrap { white-space: nowrap; }
.acts { display: flex; gap: 8px; flex-wrap: wrap; }

/* ── 徽标 ─────────────────────────────────── */
.badge {
  display: inline-flex; align-items: center; gap: 5px; padding: 3px 9px; border-radius: 999px;
  font-size: 11.5px; font-weight: 500; border: 1px solid transparent; white-space: nowrap;
}
.badge.ok { background: rgba(46, 204, 143, .12); color: var(--ok); border-color: rgba(46, 204, 143, .3); }
.badge.err { background: rgba(255, 92, 92, .12); color: var(--err); border-color: rgba(255, 92, 92, .3); }
.badge.warn { background: rgba(240, 180, 41, .12); color: var(--warn); border-color: rgba(240, 180, 41, .3); }
.badge.info { background: var(--pri-soft); color: #a9c0ff; border-color: rgba(79, 124, 255, .3); }
.badge.gray { background: #1e2430; color: var(--txt-dim); border-color: var(--line); }

/* ── Switch ───────────────────────────────── */
.switch { position: relative; display: inline-block; width: 40px; height: 22px; flex: none; }
.switch input { opacity: 0; width: 0; height: 0; position: absolute; }
.switch .sl {
  position: absolute; inset: 0; background: #2a3040; border-radius: 999px; transition: .2s;
  border: 1px solid var(--line);
}
.switch .sl:before {
  content: ""; position: absolute; height: 16px; width: 16px; left: 2px; top: 2px;
  background: #8d97ac; border-radius: 50%; transition: .2s;
}
.switch input:checked + .sl { background: var(--pri); border-color: var(--pri); }
.switch input:checked + .sl:before { transform: translateX(18px); background: #fff; }
.switch input:disabled + .sl { opacity: .45; }

.switch-row { display: flex; align-items: center; gap: 10px; }
.switch-row .lbl { font-size: 13px; color: var(--txt-dim); }

/* ── 弹窗 ─────────────────────────────────── */
.modal-mask {
  position: fixed; inset: 0; background: rgba(4, 6, 10, .72); backdrop-filter: blur(4px);
  display: flex; align-items: flex-start; justify-content: center; z-index: 100;
  padding: 40px 16px; overflow-y: auto;
}
.modal {
  background: var(--card); border: 1px solid var(--line); border-radius: 16px;
  width: 100%; max-width: 780px; box-shadow: var(--shadow); animation: pop .16s ease-out;
}
.modal.narrow { max-width: 460px; }
.modal.wide { max-width: 980px; }
@keyframes pop { from { opacity: 0; transform: translateY(-8px) scale(.99); } }
.modal-head { padding: 18px 22px; border-bottom: 1px solid var(--line-soft); display: flex; justify-content: space-between; align-items: center; }
.modal-head h3 { margin: 0; font-size: 15.5px; }
.modal-body { padding: 22px; max-height: calc(100vh - 220px); overflow-y: auto; }
.modal-foot { padding: 15px 22px; border-top: 1px solid var(--line-soft); display: flex; justify-content: flex-end; gap: 10px; }
.x-btn { background: none; border: none; color: var(--txt-faint); font-size: 20px; line-height: 1; padding: 4px 8px; border-radius: 6px; }
.x-btn:hover { background: #232938; color: var(--txt); }

/* ── 区块 ─────────────────────────────────── */
.section { border: 1px solid var(--line-soft); border-radius: 11px; padding: 16px; margin-bottom: 16px; background: #12161e; }
.section-title { font-size: 12.5px; color: var(--txt-dim); font-weight: 600; letter-spacing: .4px; margin-bottom: 13px; display: flex; align-items: center; justify-content: space-between; }

/* ── 键值编辑器 ───────────────────────────── */
.kv-row { display: grid; grid-template-columns: 1.1fr 110px 1.6fr 34px; gap: 9px; margin-bottom: 9px; align-items: center; }
@media (max-width: 700px) { .kv-row { grid-template-columns: 1fr 1fr; } }
.kv-row input, .kv-row select { padding: 8px 10px; font-size: 13px; }
.icon-btn {
  background: none; border: 1px solid var(--line); border-radius: 8px; color: var(--txt-faint);
  width: 34px; height: 34px; display: grid; place-items: center; font-size: 15px; transition: .15s;
}
.icon-btn:hover { color: var(--err); border-color: rgba(255, 92, 92, .4); background: rgba(255, 92, 92, .08); }

/* ── 空状态 ───────────────────────────────── */
.empty { padding: 48px 20px; text-align: center; color: var(--txt-faint); font-size: 13px; }
.empty .big { font-size: 30px; margin-bottom: 10px; opacity: .5; }

/* ── Toast ────────────────────────────────── */
#toast { position: fixed; right: 22px; bottom: 22px; display: flex; flex-direction: column; gap: 10px; z-index: 300; }
.toast {
  background: #1d2330; border: 1px solid var(--line); border-left: 3px solid var(--pri);
  padding: 12px 16px; border-radius: 9px; font-size: 13px; box-shadow: var(--shadow);
  animation: slidein .2s ease-out; max-width: 380px; word-break: break-word;
}
.toast.err { border-left-color: var(--err); }
.toast.ok { border-left-color: var(--ok); }
@keyframes slidein { from { opacity: 0; transform: translateX(18px); } }

/* ── 其它 ─────────────────────────────────── */
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line-soft); margin-bottom: 18px; }
.tab { padding: 9px 15px; background: none; border: none; color: var(--txt-dim); font-size: 13.5px; border-bottom: 2px solid transparent; margin-bottom: -1px; transition: .15s; }
.tab.active { color: var(--txt); border-bottom-color: var(--pri); font-weight: 600; }
.tab:hover { color: var(--txt); }

.info-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 12px; }
.info-item { background: #12161e; border: 1px solid var(--line-soft); border-radius: 10px; padding: 12px 14px; }
.info-item .k { font-size: 11.5px; color: var(--txt-faint); margin-bottom: 5px; letter-spacing: .3px; }
.info-item .v { font-size: 13.5px; word-break: break-all; }

.code-box {
  background: #0b0e14; border: 1px solid var(--line); border-radius: 9px; padding: 13px;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12px; color: #9fd0ff;
  white-space: pre-wrap; word-break: break-all; line-height: 1.65; max-height: 240px; overflow: auto;
}
.copy-inline { font-size: 11.5px; color: var(--pri); cursor: pointer; margin-left: 8px; }

.chk-list { display: flex; flex-wrap: wrap; gap: 8px; max-height: 260px; overflow-y: auto; padding: 2px; }
.chk {
  display: flex; align-items: center; gap: 8px; padding: 8px 12px; border: 1px solid var(--line);
  border-radius: 9px; font-size: 13px; cursor: pointer; background: var(--bg-soft); transition: .15s;
}
.chk:hover { border-color: #3a4356; }
.chk input { accent-color: var(--pri); }
.chk.on { border-color: var(--pri); background: var(--pri-soft); }

.pager { display: flex; align-items: center; justify-content: space-between; padding: 12px 16px; border-top: 1px solid var(--line-soft); font-size: 12.5px; color: var(--txt-faint); }

/* ── 接口完整链接（点击复制） ───────────────── */
.ep-url {
  font-size: 11.5px;
  color: var(--pri);
  cursor: pointer;
  margin-top: 4px;
  max-width: 420px;
  word-break: break-all;
  line-height: 1.5;
  opacity: .92;
  transition: .15s;
  user-select: none;
}
.ep-url:hover { opacity: 1; text-decoration: underline; }
.ep-url:active { opacity: .65; }
.ep-url.copied { color: var(--ok); }
