:root {
  --bg: #eef2f7;
  --card: #ffffff;
  --text: #1e293b;
  --muted: #64748b;
  --line: #e2e8f0;
  --primary: #2563eb;
  --primary-dark: #1d4ed8;
  --sidebar: #0f172a;
  --sidebar-2: #16233b;
  --ok: #059669;
  --warn: #d97706;
  --danger: #dc2626;
  --radius: 12px;
  --shadow: 0 1px 2px rgba(15, 23, 42, 0.06), 0 8px 24px rgba(15, 23, 42, 0.05);
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  font-size: 14px;
  line-height: 1.6;
}
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
code { font-family: var(--mono); font-size: 12px; background: #f1f5f9; padding: 1px 5px; border-radius: 4px; }
.hidden { display: none !important; }

/* ---------- 登录 ---------- */
.login-screen {
  position: relative;
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 32px 24px;
  overflow: hidden;
  background: #050b17;
  isolation: isolate;
}
.login-bg { position: absolute; inset: 0; z-index: -1; overflow: hidden; }
.login-grid {
  position: absolute; inset: -8%;
  background-image:
    linear-gradient(rgba(56, 189, 248, 0.07) 1px, transparent 1px),
    linear-gradient(90deg, rgba(56, 189, 248, 0.07) 1px, transparent 1px);
  background-size: 62px 62px;
  -webkit-mask-image: radial-gradient(circle at 50% 42%, #000 0%, transparent 72%);
  mask-image: radial-gradient(circle at 50% 42%, #000 0%, transparent 72%);
}
.login-glow { position: absolute; border-radius: 50%; filter: blur(90px); pointer-events: none; }
.login-glow-a {
  width: 640px; height: 640px; left: -180px; top: -220px;
  background: radial-gradient(circle, rgba(37, 99, 235, 0.55), transparent 64%);
}
.login-glow-b {
  width: 760px; height: 760px; right: -260px; bottom: -320px;
  background: radial-gradient(circle, rgba(14, 165, 233, 0.38), transparent 66%);
}
.login-radar {
  position: absolute; width: 560px; height: 560px; right: 4%; top: 50%;
  transform: translateY(-50%); opacity: 0.5;
}
.login-radar .ring {
  position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%);
  border-radius: 50%; border: 1px solid rgba(56, 189, 248, 0.22);
}
.login-radar .ring-1 { width: 100%; height: 100%; }
.login-radar .ring-2 { width: 68%; height: 68%; border-color: rgba(56, 189, 248, 0.16); }
.login-radar .ring-3 { width: 36%; height: 36%; border-color: rgba(56, 189, 248, 0.28); }
.login-radar .sweep {
  position: absolute; inset: 0; border-radius: 50%;
  background: conic-gradient(from 0deg, rgba(56, 189, 248, 0.34), rgba(56, 189, 248, 0.05) 42deg, transparent 70deg);
  animation: radar-sweep 7s linear infinite;
  -webkit-mask-image: radial-gradient(circle, #000 0 50%, transparent 72%);
  mask-image: radial-gradient(circle, #000 0 50%, transparent 72%);
}
.login-radar .blip {
  position: absolute; width: 7px; height: 7px; border-radius: 50%; background: #7dd3fc;
  box-shadow: 0 0 0 4px rgba(56, 189, 248, 0.14), 0 0 18px rgba(56, 189, 248, 0.8);
  animation: blip 3.2s ease-in-out infinite;
}
.login-radar .blip-1 { left: 31%; top: 27%; }
.login-radar .blip-2 { left: 63%; top: 58%; animation-delay: 0.9s; }
.login-radar .blip-3 { left: 47%; top: 71%; animation-delay: 1.8s; }
@keyframes radar-sweep { to { transform: rotate(360deg); } }
@keyframes blip {
  0%, 100% { opacity: 0.25; transform: scale(0.8); }
  50% { opacity: 1; transform: scale(1.15); }
}
.login-ticker {
  position: absolute; right: 6%; bottom: 12%; display: grid; gap: 10px;
  width: 300px; opacity: 0.3;
}
.login-ticker span {
  height: 8px; border-radius: 4px;
  background: linear-gradient(90deg, rgba(125, 211, 252, 0.55), rgba(125, 211, 252, 0));
}
.login-ticker span:nth-child(2) { width: 78%; }
.login-ticker span:nth-child(3) { width: 92%; }
.login-ticker span:nth-child(4) { width: 56%; }

.login-card {
  position: relative;
  width: 100%;
  max-width: 392px;
  background: rgba(7, 16, 30, 0.82);
  border: 1px solid rgba(125, 211, 252, 0.16);
  border-radius: 18px;
  padding: 32px 30px 28px;
  color: #e2e8f0;
  box-shadow: 0 30px 80px rgba(2, 6, 23, 0.6), inset 0 1px 0 rgba(255, 255, 255, 0.06);
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
}
.login-brand { display: flex; gap: 13px; align-items: center; margin-bottom: 26px; }
.login-brand h1 { font-size: 21px; margin: 0; color: #f8fafc; letter-spacing: -0.01em; }
.login-brand p { margin: 2px 0 0; color: #7f93ad; font-size: 12px; }
.login-logo { width: 46px; height: 46px; filter: drop-shadow(0 6px 16px rgba(37, 99, 235, 0.45)); }
.login-card label { display: block; font-size: 12px; color: #8fa3bd; margin: 0 0 6px; }
.login-card input + label { margin-top: 14px; }
.login-card input {
  width: 100%; padding: 11px 12px; border: 1px solid #1e3552; border-radius: 9px;
  font-size: 15px; outline: none; background: rgba(12, 25, 44, 0.9); color: #eaf2ff;
  transition: border-color 0.15s, box-shadow 0.15s, background 0.15s;
}
.login-card input::placeholder { color: #5b718c; }
.login-card input:focus {
  border-color: #3b82f6; background: rgba(14, 30, 52, 0.95);
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.18);
}
.login-card input:-webkit-autofill {
  -webkit-text-fill-color: #eaf2ff;
  box-shadow: 0 0 0 1000px #0d1e33 inset;
}
.login-card .form-error { color: #fca5a5; margin: 8px 0 0; }
.login-card .btn-primary {
  background: linear-gradient(135deg, #2563eb, #0284c7);
  border-color: transparent;
  box-shadow: 0 10px 24px rgba(37, 99, 235, 0.35);
}
.login-card .btn-primary:hover { background: linear-gradient(135deg, #1d4ed8, #0369a1); }

/* ---------- 布局 ---------- */
.layout { display: flex; min-height: 100%; }
.sidebar {
  width: 244px; flex: 0 0 244px; background: var(--sidebar); color: #cbd5e1;
  display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh;
}
.brand { display: flex; align-items: center; gap: 10px; padding: 20px 20px 16px; }
.brand-logo { flex: 0 0 auto; display: block; border-radius: 9px; }
.brand-text strong { color: #fff; font-size: 16px; display: block; line-height: 1.2; }
.brand-text small { color: #7c8da8; font-size: 11px; }
.nav { padding: 6px 12px; overflow-y: auto; flex: 1; }
.nav-group-label {
  font-size: 10.5px; letter-spacing: 0.08em; color: #64748b; text-transform: uppercase;
  padding: 14px 10px 6px;
}
.nav button {
  width: 100%; display: flex; align-items: center; gap: 10px; border: 0; background: transparent;
  color: #b8c5d8; padding: 9px 12px; border-radius: 8px; font-size: 13.5px; cursor: pointer;
  text-align: left; font-family: inherit;
}
.nav button:hover { background: var(--sidebar-2); color: #fff; }
.nav button.active { background: #1d3a6b; color: #fff; box-shadow: inset 3px 0 0 #3b82f6; }
.nav .ico { width: 18px; text-align: center; opacity: 0.9; font-size: 13px; }
.sidebar-foot { padding: 14px 18px 18px; border-top: 1px solid #1e2b42; }
.conn-state { display: flex; align-items: center; gap: 8px; font-size: 12px; color: #94a3b8; margin-bottom: 6px; }
.dot { width: 8px; height: 8px; border-radius: 50%; background: #22c55e; box-shadow: 0 0 0 3px rgba(34, 197, 94, 0.14); }
.dot.off { background: #ef4444; box-shadow: 0 0 0 3px rgba(239, 68, 68, 0.14); }
.version { font-size: 11px; color: #64748b; margin-bottom: 10px; }

.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar {
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  padding: 20px 28px 14px; background: rgba(238, 242, 247, 0.86); backdrop-filter: blur(8px);
  position: sticky; top: 0; z-index: 20; border-bottom: 1px solid rgba(226, 232, 240, 0.7);
}
.topbar h1 { font-size: 21px; margin: 0; letter-spacing: -0.01em; }
.topbar p { margin: 2px 0 0; color: var(--muted); font-size: 12.5px; max-width: 720px; }
.topbar-actions { display: flex; gap: 8px; flex-wrap: wrap; justify-content: flex-end; }
.content { padding: 18px 28px 48px; max-width: 1180px; width: 100%; }

/* ---------- 按钮 / 表单 ---------- */
.btn {
  border: 1px solid var(--line); background: #fff; color: var(--text); border-radius: 8px;
  padding: 8px 14px; font-size: 13px; font-family: inherit; cursor: pointer; line-height: 1.4;
  display: inline-flex; align-items: center; gap: 6px; white-space: nowrap;
}
.btn:hover { border-color: #cbd5e1; background: #f8fafc; }
.btn:disabled { opacity: 0.55; cursor: not-allowed; }
.btn-primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dark); border-color: var(--primary-dark); }
.btn-danger { color: var(--danger); border-color: #fecaca; background: #fef2f2; }
.btn-ghost { background: transparent; border-color: transparent; color: inherit; }
.btn-small { padding: 5px 10px; font-size: 12px; }
.btn-block { width: 100%; justify-content: center; padding: 11px; font-size: 14px; margin-top: 14px; }

.card {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 20px 22px; margin-bottom: 16px;
}
.card-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; margin-bottom: 4px; }
.card h2 { font-size: 15.5px; margin: 0; }
.card .sub { color: var(--muted); font-size: 12.5px; margin: 3px 0 16px; }
.card-section-title { font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.04em; margin: 18px 0 10px; }

.field { padding: 12px 0; border-bottom: 1px dashed #eef2f7; }
.field:last-child { border-bottom: 0; }
.field-row { display: flex; align-items: flex-start; justify-content: space-between; gap: 22px; }
.field-label { font-size: 13px; font-weight: 500; color: #334155; }
.field-help { color: var(--muted); font-size: 12px; margin-top: 3px; max-width: 620px; }
.field-input { min-width: 260px; max-width: 360px; width: 100%; flex: 0 0 auto; }
.field-error { color: var(--danger); font-size: 12px; margin-top: 5px; }
.field-inline { display: flex; gap: 8px; align-items: center; }
input[type="text"], input[type="password"], input[type="number"], select, textarea {
  width: 100%; border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px;
  font-size: 13.5px; font-family: inherit; background: #fff; color: var(--text); outline: none;
}
input:focus, select:focus, textarea:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1); }
input::placeholder, textarea::placeholder { color: #a3b0c2; }
textarea { resize: vertical; min-height: 90px; font-family: var(--mono); font-size: 12.5px; line-height: 1.6; }
textarea.code { min-height: 360px; }
select { appearance: none; background-image: linear-gradient(45deg, transparent 50%, #64748b 50%), linear-gradient(135deg, #64748b 50%, transparent 50%); background-position: calc(100% - 16px) 55%, calc(100% - 11px) 55%; background-size: 5px 5px; background-repeat: no-repeat; padding-right: 32px; }

.switch { position: relative; display: inline-block; width: 44px; height: 24px; flex: 0 0 auto; }
.switch input { opacity: 0; width: 0; height: 0; }
.switch span { position: absolute; inset: 0; background: #cbd5e1; border-radius: 24px; transition: 0.18s; cursor: pointer; }
.switch span::after { content: ""; position: absolute; width: 18px; height: 18px; left: 3px; top: 3px; background: #fff; border-radius: 50%; transition: 0.18s; box-shadow: 0 1px 3px rgba(0,0,0,0.2); }
.switch input:checked + span { background: var(--primary); }
.switch input:checked + span::after { transform: translateX(20px); }
.switch input:focus + span { box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.18); }

/* ---------- 概览 ---------- */
.grid { display: grid; gap: 14px; }
.grid.cols-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.grid.cols-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid.cols-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.stat { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; box-shadow: var(--shadow); }
.stat .k { color: var(--muted); font-size: 12px; }
.stat .v { font-size: 21px; font-weight: 650; margin-top: 2px; letter-spacing: -0.02em; }
.stat .v small { font-size: 12px; font-weight: 400; color: var(--muted); margin-left: 4px; }
.badge { display: inline-flex; align-items: center; gap: 5px; padding: 2px 9px; border-radius: 99px; font-size: 11.5px; font-weight: 500; }
.badge.ok { background: #ecfdf5; color: var(--ok); }
.badge.warn { background: #fffbeb; color: var(--warn); }
.badge.err { background: #fef2f2; color: var(--danger); }
.badge.info { background: #eff6ff; color: var(--primary); }
.badge.muted { background: #f1f5f9; color: var(--muted); }
.mono { font-family: var(--mono); font-size: 12px; }
.muted { color: var(--muted); }
.small { font-size: 12px; }

.note { display: flex; gap: 8px; padding: 9px 12px; border-radius: 8px; font-size: 12.5px; margin-bottom: 8px; }
.note.warn { background: #fffbeb; color: #92400e; }
.note.info { background: #eff6ff; color: #1e40af; }
.note.error { background: #fef2f2; color: #991b1b; }

.quick-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.status-line { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.kv { display: grid; grid-template-columns: 110px 1fr; gap: 6px 14px; font-size: 13px; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; word-break: break-all; }

/* ---------- 表格 ---------- */
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th, td { text-align: left; padding: 9px 10px; border-bottom: 1px solid #eef2f7; vertical-align: middle; }
th { color: var(--muted); font-weight: 500; font-size: 11.5px; text-transform: uppercase; letter-spacing: 0.03em; }
tr:last-child td { border-bottom: 0; }
.table-wrap { overflow-x: auto; }

/* ---------- 配置指南 ---------- */
.guide { margin: 14px 0 4px; border: 1px solid var(--line); border-radius: 10px; overflow: hidden; }
.guide-title { padding: 9px 12px; background: #f8fafc; font-size: 12px; color: var(--muted); font-weight: 600; }
.guide-item { border-top: 1px solid #eef2f7; padding: 0 12px; }
.guide-item summary { cursor: pointer; padding: 10px 0; font-size: 13px; font-weight: 500; }
.guide-item[open] summary { color: var(--primary); }
.guide-item ol { margin: 0 0 10px 18px; padding: 0; font-size: 12.5px; color: #475569; }
.guide-item li { margin-bottom: 4px; }
.guide-example { display: flex; gap: 8px; align-items: flex-start; margin: 2px 0 10px; font-size: 12px; }
.guide-example span { color: var(--muted); flex: 0 0 auto; }
.guide-example code { background: #f1f5f9; padding: 3px 6px; border-radius: 5px; word-break: break-all; white-space: pre-wrap; }
.kw-group textarea { min-height: 140px; }

/* ---------- 对象列表 ---------- */
.object-item { border: 1px solid var(--line); border-radius: 10px; padding: 12px 14px; margin-bottom: 10px; background: #fbfdff; }
.object-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 8px; }
.object-title { font-size: 13px; font-weight: 600; }
.object-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px 14px; }
.object-grid .full { grid-column: 1 / -1; }
.object-grid label { display: block; font-size: 11.5px; color: var(--muted); margin-bottom: 4px; }
.object-actions { display: flex; gap: 6px; }
.empty { border: 1px dashed #cbd5e1; border-radius: 10px; padding: 22px; text-align: center; color: var(--muted); font-size: 13px; }

/* ---------- 顺序编辑器 ---------- */
.order-row { display: flex; align-items: center; gap: 10px; padding: 7px 10px; border: 1px solid var(--line); border-radius: 8px; margin-bottom: 7px; background: #fff; }
.order-row .idx { width: 20px; color: var(--muted); font-size: 12px; }
.order-row .grow { flex: 1; }

/* ---------- 日志 ---------- */
.log-view {
  background: #0b1220; color: #cbd5e1; border-radius: 10px; padding: 14px 16px;
  font-family: var(--mono); font-size: 12px; line-height: 1.65; white-space: pre-wrap;
  word-break: break-word; max-height: 480px; overflow: auto; min-height: 120px;
}
.log-view .ok { color: #4ade80; }
.log-meta { display: flex; justify-content: space-between; align-items: center; gap: 10px; margin-bottom: 8px; }

/* ---------- 文件编辑 ---------- */
.file-layout { display: grid; grid-template-columns: 240px minmax(0, 1fr); gap: 16px; align-items: start; }
.file-list { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.file-list button { display: block; width: 100%; text-align: left; border: 0; background: transparent; padding: 10px 12px; cursor: pointer; font-family: inherit; font-size: 13px; border-bottom: 1px solid #eef2f7; color: var(--text); }
.file-list button:hover { background: #f8fafc; }
.file-list button.active { background: #eff6ff; color: var(--primary); box-shadow: inset 3px 0 0 var(--primary); }
.file-list .meta { display: block; font-size: 11px; color: var(--muted); margin-top: 2px; }
.editor-head { display: flex; justify-content: space-between; align-items: center; gap: 10px; margin-bottom: 10px; }
.preview-box { margin-top: 14px; border-top: 1px solid var(--line); padding-top: 12px; }
.preview-box h3 { font-size: 13px; margin: 0 0 8px; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { background: #f1f5f9; border-radius: 6px; padding: 2px 8px; font-size: 12px; }

/* ---------- 提示 / 加载 ---------- */
.toast {
  position: fixed; right: 20px; bottom: 20px; z-index: 100;
  background: #0f172a; color: #fff; padding: 11px 16px; border-radius: 10px;
  font-size: 13px; box-shadow: 0 10px 30px rgba(2, 6, 23, 0.35); max-width: 380px;
}
.toast.err { background: #7f1d1d; }
.toast.ok { background: #064e3b; }
.toast.hidden { display: none; }
.loading { padding: 40px; text-align: center; color: var(--muted); font-size: 13px; }
.spinner { display: inline-block; width: 16px; height: 16px; border: 2px solid #cbd5e1; border-top-color: var(--primary); border-radius: 50%; animation: spin 0.8s linear infinite; vertical-align: -3px; margin-right: 6px; }
@keyframes spin { to { transform: rotate(360deg); } }

.form-error { color: var(--danger); font-size: 12.5px; margin: 8px 0 0; }
.save-bar { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 14px 0 0; }

@media (max-width: 980px) {
  .grid.cols-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .grid.cols-3 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .file-layout { grid-template-columns: 1fr; }
}
@media (max-width: 820px) {
  .layout { flex-direction: column; }
  .sidebar { width: auto; flex: none; height: auto; position: static; }
  .brand { padding: 14px 16px 8px; }
  .nav { display: flex; overflow-x: auto; padding: 4px 10px 10px; gap: 4px; }
  .nav-group-label { display: none; }
  .nav button { width: auto; white-space: nowrap; padding: 8px 12px; }
  .sidebar-foot { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 8px 16px 12px; border-top: 0; }
  .version { display: none; }
  .topbar { padding: 14px 16px 10px; flex-direction: column; align-items: flex-start; }
  .topbar-actions { justify-content: flex-start; }
  .content { padding: 12px 16px 40px; }
  .field-row { flex-direction: column; gap: 8px; }
  .field-input { max-width: 100%; min-width: 0; }
  .grid.cols-4, .grid.cols-3, .grid.cols-2 { grid-template-columns: 1fr; }
  .object-grid { grid-template-columns: 1fr; }
  .kv { grid-template-columns: 90px 1fr; }
  .login-radar { right: -170px; width: 420px; height: 420px; opacity: 0.28; }
  .login-ticker { display: none; }
  .login-card { padding: 26px 22px 22px; }
  .login-logo { width: 42px; height: 42px; }
}