:root {
  --bg: #f5f7fb;
  --panel: #ffffff;
  --line: #e7eaf3;
  --line-soft: #f0f2f8;
  --text: #0f172a;
  --muted: #64748b;
  --faint: #94a3b8;
  --brand: #4f46e5;
  --brand-2: #06b6d4;
  --brand-soft: #eef2ff;
  --green: #059669;
  --green-soft: #ecfdf5;
  --amber: #d97706;
  --amber-soft: #fffbeb;
  --red: #dc2626;
  --red-soft: #fef2f2;
  --gray-soft: #f1f5f9;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(15, 23, 42, .04), 0 4px 16px rgba(15, 23, 42, .05);
  --mono: ui-monospace, "SF Mono", "JetBrains Mono", Menlo, Consolas, monospace;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  font: 14px/1.55 "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}
button, input { font: inherit; color: inherit; }
code, .mono { font-family: var(--mono); font-size: 12.5px; }
.muted { color: var(--muted); }
.faint { color: var(--faint); }
.hidden { display: none !important; }

/* ---------- 登录 ---------- */
.login {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
  background:
    radial-gradient(600px 400px at 15% 10%, rgba(99, 102, 241, .16), transparent 60%),
    radial-gradient(500px 380px at 90% 90%, rgba(6, 182, 212, .16), transparent 60%),
    var(--bg);
}
.login-card {
  width: 100%;
  max-width: 380px;
  background: rgba(255, 255, 255, .85);
  backdrop-filter: blur(12px);
  border: 1px solid var(--line);
  border-radius: 20px;
  box-shadow: 0 20px 60px rgba(79, 70, 229, .12);
  padding: 36px 32px 32px;
}
.login-card .logo { margin-bottom: 26px; }
.login-card h1 { margin: 0 0 4px; font-size: 22px; letter-spacing: -.01em; }
.login-card p { margin: 0 0 22px; }
.login-card .btn { width: 100%; justify-content: center; height: 42px; margin-top: 14px; }

/* ---------- 布局 ---------- */
.shell { display: grid; grid-template-columns: 232px 1fr; min-height: 100vh; }
.side {
  position: sticky; top: 0; height: 100vh;
  padding: 22px 14px;
  background: var(--panel);
  border-right: 1px solid var(--line);
  display: flex; flex-direction: column; gap: 4px;
}
.logo { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 16px; padding: 0 10px 18px; }
.logo-mark {
  width: 32px; height: 32px; border-radius: 9px; display: grid; place-items: center;
  background: linear-gradient(135deg, var(--brand), var(--brand-2)); color: #fff;
  box-shadow: 0 6px 16px rgba(79, 70, 229, .3);
}
.nav a {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 12px; border-radius: 10px;
  color: var(--muted); text-decoration: none; font-weight: 500;
  transition: background .15s, color .15s;
}
.nav a:hover { background: var(--line-soft); color: var(--text); }
.nav a.active { background: var(--brand-soft); color: var(--brand); }
.nav .count {
  margin-left: auto; min-width: 20px; padding: 0 6px; border-radius: 10px;
  background: var(--amber); color: #fff; font-size: 11px; text-align: center; line-height: 18px;
}
.side-foot { margin-top: auto; padding: 12px; font-size: 12px; color: var(--faint); }
.side-foot .btn { width: 100%; justify-content: center; margin-top: 10px; }

main { padding: 30px 36px 60px; max-width: 1180px; width: 100%; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 22px; }
.page-head h2 { margin: 0; font-size: 22px; letter-spacing: -.01em; }
.page-head p { margin: 4px 0 0; color: var(--muted); }

/* ---------- 组件 ---------- */
.card {
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.card-pad { padding: 20px 22px; }
.card-head { display: flex; align-items: center; justify-content: space-between; padding: 16px 22px; border-bottom: 1px solid var(--line-soft); }
.card-head h3 { margin: 0; font-size: 15px; }
.section { margin-top: 22px; }

.grid-stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; }
.stat { padding: 18px 20px; position: relative; overflow: hidden; }
.stat .label { color: var(--muted); font-size: 13px; display: flex; align-items: center; gap: 8px; }
.stat .value { font-size: 28px; font-weight: 700; letter-spacing: -.02em; margin-top: 6px; }
.stat .sub { font-size: 12px; color: var(--faint); }
.stat .icon {
  width: 30px; height: 30px; border-radius: 9px; display: grid; place-items: center;
}
.ic-indigo { background: var(--brand-soft); color: var(--brand); }
.ic-cyan { background: #ecfeff; color: #0891b2; }
.ic-green { background: var(--green-soft); color: var(--green); }
.ic-amber { background: var(--amber-soft); color: var(--amber); }

.btn {
  display: inline-flex; align-items: center; gap: 6px;
  height: 34px; padding: 0 14px; border-radius: 9px;
  border: 1px solid var(--line); background: var(--panel);
  font-weight: 500; cursor: pointer; white-space: nowrap;
  transition: background .15s, border-color .15s, box-shadow .15s, transform .05s;
}
.btn:hover { background: var(--line-soft); }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn-primary { background: var(--brand); border-color: var(--brand); color: #fff; box-shadow: 0 4px 12px rgba(79, 70, 229, .25); }
.btn-primary:hover { background: #4338ca; }
.btn-success { background: var(--green); border-color: var(--green); color: #fff; }
.btn-success:hover { background: #047857; }
.btn-danger { color: var(--red); }
.btn-danger:hover { background: var(--red-soft); border-color: #fecaca; }
.btn-sm { height: 28px; padding: 0 10px; font-size: 13px; border-radius: 8px; }
.btn-ghost { border-color: transparent; background: transparent; }

.input {
  width: 100%; height: 40px; padding: 0 12px;
  border: 1px solid var(--line); border-radius: 10px; background: #fff;
  outline: none; transition: border-color .15s, box-shadow .15s;
}
.input:focus { border-color: var(--brand); box-shadow: 0 0 0 4px rgba(79, 70, 229, .12); }
.field { display: block; margin-bottom: 14px; }
.field span { display: block; font-size: 13px; font-weight: 500; margin-bottom: 6px; }
.err { color: var(--red); font-size: 13px; min-height: 20px; margin-top: 8px; }

.pill {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 2px 10px; border-radius: 999px; font-size: 12px; font-weight: 600; line-height: 20px;
}
.pill::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.pill-green { background: var(--green-soft); color: var(--green); }
.pill-amber { background: var(--amber-soft); color: var(--amber); }
.pill-red { background: var(--red-soft); color: var(--red); }
.pill-gray { background: var(--gray-soft); color: var(--muted); }
.pill-indigo { background: var(--brand-soft); color: var(--brand); }

.copybox {
  display: flex; align-items: center; gap: 8px;
  background: var(--line-soft); border: 1px solid var(--line); border-radius: 10px;
  padding: 6px 6px 6px 12px;
}
.copybox code { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.kv { display: grid; grid-template-columns: 110px 1fr; gap: 12px 16px; align-items: center; }
.kv > .k { color: var(--muted); font-size: 13px; }

table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 11px 22px; border-bottom: 1px solid var(--line-soft); vertical-align: middle; }
th { font-size: 12px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; background: #fafbfe; }
tr:last-child td { border-bottom: 0; }
tbody tr:hover td { background: #fafbff; }
.empty { padding: 36px 22px; text-align: center; color: var(--faint); }

/* 服务卡片 */
.svc-list { display: grid; gap: 14px; }
.svc { overflow: hidden; }
.svc-top { display: flex; align-items: center; gap: 14px; padding: 16px 20px; }
.svc-avatar {
  width: 40px; height: 40px; border-radius: 11px; flex: none;
  display: grid; place-items: center; font-weight: 700; color: #fff; text-transform: uppercase;
}
.av0 { background: linear-gradient(135deg, #6366f1, #8b5cf6); }
.av1 { background: linear-gradient(135deg, #06b6d4, #3b82f6); }
.av2 { background: linear-gradient(135deg, #10b981, #14b8a6); }
.av3 { background: linear-gradient(135deg, #f59e0b, #f97316); }
.av4 { background: linear-gradient(135deg, #ec4899, #f43f5e); }
.av5 { background: linear-gradient(135deg, #0ea5e9, #6366f1); }
.svc-main { flex: 1; min-width: 0; }
.svc-name { font-weight: 600; font-size: 15px; display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.svc-meta { font-size: 12.5px; color: var(--muted); margin-top: 2px; }
.svc-actions { display: flex; align-items: center; gap: 8px; }
.svc-alert {
  margin: 0 20px 14px; padding: 10px 14px; border-radius: 10px;
  background: var(--amber-soft); border: 1px solid #fde68a; color: #92400e; font-size: 13px;
}
.svc-alert .tags { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 6px; }
.tag { font-family: var(--mono); font-size: 12px; padding: 1px 8px; border-radius: 6px; background: #fff; border: 1px solid var(--line); }
.tag-add { color: var(--green); border-color: #a7f3d0; }
.tag-del { color: var(--red); border-color: #fecaca; text-decoration: line-through; }
.tag-mod { color: var(--amber); border-color: #fde68a; }
.tools { border-top: 1px solid var(--line-soft); background: #fbfcfe; }
.tool { display: grid; grid-template-columns: 220px 1fr; gap: 16px; padding: 10px 20px; border-bottom: 1px solid var(--line-soft); font-size: 13px; }
.tool:last-child { border-bottom: 0; }
.tool code { color: var(--brand); word-break: break-all; }
.tool .desc { color: var(--muted); overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }

.switch { position: relative; width: 38px; height: 22px; flex: none; cursor: pointer; }
.switch input { opacity: 0; width: 0; height: 0; position: absolute; }
.switch .track { position: absolute; inset: 0; border-radius: 999px; background: #cbd5e1; transition: background .2s; }
.switch .track::after {
  content: ""; position: absolute; top: 3px; left: 3px; width: 16px; height: 16px; border-radius: 50%;
  background: #fff; box-shadow: 0 1px 3px rgba(0, 0, 0, .2); transition: transform .2s;
}
.switch input:checked + .track { background: var(--green); }
.switch input:checked + .track::after { transform: translateX(16px); }
.switch input:disabled + .track { opacity: .5; cursor: not-allowed; }

.notice {
  display: flex; gap: 12px; align-items: flex-start;
  padding: 14px 18px; border-radius: 12px; border: 1px solid #fde68a; background: var(--amber-soft); color: #92400e;
}
.notice a { color: inherit; font-weight: 600; }

.tabs { display: inline-flex; background: var(--line-soft); border-radius: 10px; padding: 3px; gap: 2px; }
.tabs button { border: 0; background: transparent; padding: 6px 14px; border-radius: 8px; cursor: pointer; color: var(--muted); font-weight: 500; }
.tabs button.on { background: #fff; color: var(--text); box-shadow: 0 1px 3px rgba(15, 23, 42, .08); }

.inline-form { display: flex; gap: 10px; }
.inline-form .input { height: 34px; max-width: 260px; }

/* 弹窗 */
.modal-back {
  position: fixed; inset: 0; background: rgba(15, 23, 42, .35); backdrop-filter: blur(3px);
  display: grid; place-items: center; padding: 20px; z-index: 50; animation: fade .15s;
}
.modal { width: 100%; max-width: 560px; background: #fff; border-radius: 18px; box-shadow: 0 30px 80px rgba(15, 23, 42, .25); padding: 26px; animation: pop .18s; }
.modal h3 { margin: 0 0 6px; font-size: 18px; }
.modal p { margin: 0 0 16px; color: var(--muted); }
.modal pre {
  margin: 8px 0 0; padding: 12px 14px; border-radius: 10px; background: #0f172a; color: #e2e8f0;
  font-family: var(--mono); font-size: 12px; overflow-x: auto; white-space: pre;
}
.modal-foot { display: flex; justify-content: flex-end; gap: 10px; margin-top: 20px; }
.secret { font-family: var(--mono); font-size: 13px; word-break: break-all; background: var(--brand-soft); color: var(--brand); padding: 12px 14px; border-radius: 10px; border: 1px dashed #c7d2fe; }

#toasts { position: fixed; right: 20px; bottom: 20px; display: grid; gap: 8px; z-index: 60; }
.toast {
  padding: 10px 16px; border-radius: 10px; background: #0f172a; color: #fff; font-size: 13px;
  box-shadow: 0 10px 30px rgba(15, 23, 42, .25); animation: pop .18s;
}
.toast.toast-bad { background: var(--red); color: #fff; }

@keyframes fade { from { opacity: 0; } }
@keyframes pop { from { opacity: 0; transform: translateY(6px) scale(.98); } }

.ok { color: var(--green); }
.bad { color: var(--red); }
.row { display: flex; align-items: center; gap: 10px; }
.spacer { flex: 1; }
.two { display: grid; grid-template-columns: 1.4fr 1fr; gap: 16px; }

@media (max-width: 960px) {
  .shell { grid-template-columns: 1fr; }
  .side { position: static; height: auto; flex-direction: row; flex-wrap: wrap; align-items: center; padding: 12px; }
  .logo { padding: 0 10px 0 4px; }
  .nav { display: flex; gap: 2px; flex-wrap: wrap; }
  .side-foot { display: none; }
  main { padding: 20px 16px 40px; }
  .grid-stats { grid-template-columns: repeat(2, 1fr); }
  .two { grid-template-columns: 1fr; }
  .tool { grid-template-columns: 1fr; gap: 2px; }
  th, td { padding: 10px 12px; }
}
