:root {
  color-scheme: dark;
  --bg: #070c12;
  --bg-soft: #0a1119;
  --panel: #0d1620;
  --panel-2: #111d28;
  --line: rgba(255, 255, 255, 0.08);
  --line-strong: rgba(255, 255, 255, 0.14);
  --text: #e8eef5;
  --muted: #8296a8;
  --muted-2: #5d6f80;
  --accent: #2fd4ce;
  --accent-soft: rgba(47, 212, 206, 0.12);
  --accent-line: rgba(47, 212, 206, 0.4);
  --accent-ink: #04222a;
  --warning: #e8a33d;
  --danger: #ef6b62;
  --radius: 8px;
  --radius-card: 12px;
  --font-sans: "Inter", "SF Pro Text", "PingFang SC", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --font-mono: "JetBrains Mono", ui-monospace, "SF Mono", Menlo, Consolas, monospace;
}

* { box-sizing: border-box; }

html, body { margin: 0; padding: 0; }

body {
  min-height: 100vh;
  background:
    radial-gradient(900px 420px at 12% -10%, rgba(47, 212, 206, 0.10), transparent 70%),
    radial-gradient(700px 360px at 92% 0%, rgba(47, 212, 206, 0.05), transparent 65%),
    var(--bg);
  color: var(--text);
  font-family: var(--font-sans);
  font-size: 14px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  display: flex;
  flex-direction: column;
}

a { color: inherit; text-decoration: none; }
button { font-family: inherit; }
[hidden] { display: none !important; }

.wrap {
  width: 100%;
  max-width: 1240px;
  margin: 0 auto;
  padding: 0 24px;
}

/* ---------- 顶栏 ---------- */
.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  background: rgba(7, 12, 18, 0.88);
  backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--line);
}

.topbar-inner {
  height: 60px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.brand { display: flex; align-items: center; gap: 10px; min-width: 0; }

.brand-mark {
  width: 30px;
  height: 30px;
  border-radius: 9px;
  display: grid;
  place-items: center;
  background: var(--accent-soft);
  border: 1px solid var(--accent-line);
  color: var(--accent);
  font-weight: 600;
  font-size: 14px;
  flex: none;
}

.brand-text { display: flex; flex-direction: column; line-height: 1.25; min-width: 0; }
.brand-name { font-size: 14px; font-weight: 600; letter-spacing: 0.2px; }
.brand-sub { font-size: 11px; color: var(--muted-2); font-family: var(--font-mono); }

.topbar-actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; justify-content: flex-end; }

.user-chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 3px 12px 3px 3px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--panel);
}

.avatar {
  width: 24px;
  height: 24px;
  border-radius: 999px;
  display: grid;
  place-items: center;
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 12px;
  font-weight: 600;
}

.user-name { font-size: 12px; color: var(--text); }

/* ---------- 按钮 ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border-radius: var(--radius);
  border: 1px solid var(--line);
  background: transparent;
  color: var(--muted);
  font-size: 13px;
  font-weight: 500;
  padding: 6px 14px;
  cursor: pointer;
  transition: color .15s ease, border-color .15s ease, background .15s ease;
  white-space: nowrap;
}

.btn:hover { color: var(--text); border-color: var(--line-strong); }

.btn-primary {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--accent-ink);
}
.btn-primary:hover { color: var(--accent-ink); filter: brightness(1.06); }

.btn-ghost { background: transparent; }

.btn-danger { color: var(--danger); border-color: rgba(239, 107, 98, 0.32); }
.btn-danger:hover { color: var(--danger); border-color: var(--danger); background: rgba(239, 107, 98, 0.08); }

.btn-sm { padding: 4px 10px; font-size: 12px; }
.btn:disabled { opacity: .45; cursor: not-allowed; }

.icon-btn {
  width: 26px;
  height: 26px;
  display: inline-grid;
  place-items: center;
  border-radius: 6px;
  border: 1px solid transparent;
  background: transparent;
  color: var(--muted-2);
  cursor: pointer;
  font-size: 13px;
  line-height: 1;
}
.icon-btn:hover { color: var(--text); border-color: var(--line); }

/* ---------- 页面主体 ---------- */
main.wrap { flex: 1; padding-top: 24px; padding-bottom: 32px; }

.stats {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 16px;
  margin-bottom: 20px;
}

.stat {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius-card);
  padding: 14px 18px 16px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-width: 0;
}

.stat-label { font-size: 12px; color: var(--muted); }
.stat-value {
  font-size: 30px;
  font-weight: 600;
  line-height: 1.1;
  letter-spacing: -0.5px;
  font-variant-numeric: tabular-nums;
}
.stat-value.is-text { font-size: 20px; letter-spacing: 0; }
.stat-value.is-accent { color: var(--accent); }

.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius-card);
  padding: 18px 20px 20px;
}

.panel + .panel { margin-top: 16px; }

.panel-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 16px;
}

.panel-title { margin: 0; font-size: 15px; font-weight: 600; letter-spacing: .2px; }
.panel-sub { margin: 4px 0 0; font-size: 12px; color: var(--muted-2); }

.search {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 240px;
  padding: 7px 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--bg-soft);
  color: var(--muted-2);
}

.search:focus-within { border-color: var(--accent-line); }
.search svg { width: 14px; height: 14px; flex: none; }

.search input {
  flex: 1;
  min-width: 0;
  background: transparent;
  border: 0;
  outline: none;
  color: var(--text);
  font-size: 13px;
}
.search input::placeholder { color: var(--muted-2); }

/* ---------- 应用卡片 ---------- */
.app-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
}

.app-card {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: var(--radius-card);
  background: var(--bg-soft);
  transition: border-color .16s ease, background .16s ease, transform .16s ease;
  min-width: 0;
}
.app-card:hover {
  border-color: var(--accent-line);
  background: var(--panel-2);
  transform: translateY(-2px);
}
.app-card[hidden] { display: none; }

.app-icon {
  width: 38px;
  height: 38px;
  flex: none;
  border-radius: 10px;
  display: grid;
  place-items: center;
  background: var(--accent-soft);
  border: 1px solid rgba(47, 212, 206, 0.18);
  color: var(--accent);
  font-size: 15px;
  font-weight: 600;
}
.app-icon.sm { width: 28px; height: 28px; border-radius: 8px; font-size: 13px; }

.app-body { display: flex; flex-direction: column; gap: 2px; min-width: 0; flex: 1; }
.app-name { font-size: 14px; font-weight: 600; color: var(--text); }
.app-desc {
  font-size: 12px;
  color: var(--muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.app-host { font-size: 11px; color: var(--muted-2); font-family: var(--font-mono); overflow-wrap: anywhere; }

.tag {
  font-size: 11px;
  padding: 1px 8px;
  border-radius: 999px;
  border: 1px solid rgba(47, 212, 206, 0.28);
  color: var(--accent);
  flex: none;
  white-space: nowrap;
}
.tag-lock { border-color: var(--line); color: var(--muted-2); }

.empty {
  padding: 40px 0;
  text-align: center;
  color: var(--muted-2);
  font-size: 13px;
}

/* ---------- 配置页 ---------- */
.page-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 18px;
}
.page-title { margin: 0; font-size: 20px; font-weight: 600; letter-spacing: -0.2px; }
.page-sub { margin: 4px 0 0; font-size: 12px; color: var(--muted-2); }

.table-wrap { width: 100%; overflow-x: auto; }

.table { width: 100%; border-collapse: collapse; min-width: 720px; }
.table th {
  text-align: left;
  font-size: 11px;
  font-weight: 500;
  letter-spacing: .6px;
  color: var(--muted-2);
  padding: 0 12px 10px;
  border-bottom: 1px solid var(--line);
  white-space: nowrap;
}
.table td {
  padding: 12px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
  font-size: 13px;
  color: var(--text);
  vertical-align: middle;
}
.table tr:last-child td { border-bottom: 0; }
.table tbody tr:hover td { background: rgba(255, 255, 255, 0.02); }

.cell-app { display: flex; align-items: center; gap: 10px; min-width: 0; }
.cell-name { font-size: 13px; font-weight: 600; }
.cell-url { font-size: 11px; color: var(--muted-2); font-family: var(--font-mono); overflow-wrap: anywhere; }
.cell-muted { color: var(--muted); font-size: 12px; }
.cell-ops { text-align: right; white-space: nowrap; }
.cell-ops .btn, .cell-ops .icon-btn { margin-left: 4px; }
.order-num { font-family: var(--font-mono); font-size: 12px; color: var(--muted-2); }

.switch {
  width: 34px;
  height: 18px;
  border-radius: 999px;
  border: 1px solid var(--line-strong);
  background: var(--bg-soft);
  position: relative;
  cursor: pointer;
  padding: 0;
  transition: background .16s ease, border-color .16s ease;
}
.switch-dot {
  position: absolute;
  top: 2px;
  left: 2px;
  width: 12px;
  height: 12px;
  border-radius: 999px;
  background: var(--muted-2);
  transition: transform .16s ease, background .16s ease;
}
.switch.is-on { background: rgba(47, 212, 206, 0.18); border-color: var(--accent-line); }
.switch.is-on .switch-dot { transform: translateX(16px); background: var(--accent); }

/* ---------- 弹窗 ---------- */
.modal { position: fixed; inset: 0; z-index: 50; display: grid; place-items: center; padding: 24px; }
.modal-mask { position: absolute; inset: 0; background: rgba(4, 8, 12, 0.7); backdrop-filter: blur(3px); }
.modal-card {
  position: relative;
  width: 100%;
  max-width: 420px;
  max-height: calc(100vh - 48px);
  overflow-y: auto;
  background: var(--panel);
  border: 1px solid var(--line-strong);
  border-radius: 14px;
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.55);
}
.modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 16px 18px;
  border-bottom: 1px solid var(--line);
}
.modal-head h3 { margin: 0; font-size: 15px; font-weight: 600; }
.modal-body { padding: 18px; display: flex; flex-direction: column; gap: 14px; }
.modal-foot {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  padding: 0 18px 18px;
}

.field { display: flex; flex-direction: column; gap: 6px; }
.field > span { font-size: 12px; color: var(--muted); }
.field input[type="text"], .field input[type="password"], .field input[type="number"], .field input:not([type]) {
  width: 100%;
  padding: 8px 12px;
  border-radius: var(--radius);
  border: 1px solid var(--line);
  background: var(--bg-soft);
  color: var(--text);
  font-size: 13px;
  outline: none;
}
.field input:focus { border-color: var(--accent-line); }
.field-inline { flex-direction: row; align-items: center; justify-content: space-between; }
.field-inline input { width: 16px; height: 16px; accent-color: var(--accent); }

.form-hint { margin: 0; font-size: 12px; color: var(--muted-2); }
.form-error {
  margin: 0;
  font-size: 12px;
  color: var(--danger);
  background: rgba(239, 107, 98, 0.1);
  border: 1px solid rgba(239, 107, 98, 0.28);
  border-radius: var(--radius);
  padding: 8px 12px;
}
.confirm-text { margin: 0; font-size: 13px; color: var(--muted); line-height: 1.7; }

/* ---------- 提示 ---------- */
.toast {
  position: fixed;
  left: 50%;
  bottom: 32px;
  transform: translateX(-50%);
  z-index: 60;
  padding: 9px 18px;
  border-radius: 999px;
  background: var(--panel-2);
  border: 1px solid var(--accent-line);
  color: var(--text);
  font-size: 13px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.45);
}
.toast.is-error { border-color: rgba(239, 107, 98, 0.5); color: #ffd9d5; }

/* ---------- 页脚 ---------- */
.footer {
  padding: 18px 24px 24px;
  text-align: center;
  font-size: 11px;
  color: var(--muted-2);
}
.footer-dot { margin: 0 6px; }

.footer-link {
  background: transparent;
  border: 0;
  padding: 0;
  cursor: pointer;
  font-size: 11px;
  font-family: var(--font-mono);
  color: var(--muted);
  text-decoration: underline;
  text-underline-offset: 3px;
  text-decoration-color: var(--line-strong);
}
.footer-link:hover { color: var(--accent); }

/* ---------- 更新日志 ---------- */
.log { display: flex; flex-direction: column; gap: 18px; }
.log-item { border-left: 2px solid var(--line); padding-left: 14px; }
.log-item:first-child { border-left-color: var(--accent-line); }
.log-head { display: flex; align-items: baseline; gap: 10px; margin-bottom: 6px; }
.log-ver { font-size: 14px; font-weight: 600; font-family: var(--font-mono); color: var(--text); }
.log-date { font-size: 11px; color: var(--muted-2); font-family: var(--font-mono); }
.log-list { margin: 0; padding-left: 16px; display: flex; flex-direction: column; gap: 3px; }
.log-list li { font-size: 12px; color: var(--muted); line-height: 1.7; }

/* ---------- 响应式 ---------- */
@media (max-width: 1024px) {
  .app-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 720px) {
  .wrap { padding: 0 16px; }
  .app-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .panel { padding: 14px; }
  .panel-head { flex-direction: column; align-items: stretch; }
  .search { min-width: 0; width: 100%; }
  .brand-sub { display: none; }
  .page-head { flex-direction: column; align-items: flex-start; }
}

@media (max-width: 480px) {
  .app-grid { grid-template-columns: minmax(0, 1fr); }
  .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .stat-value { font-size: 24px; }
}
