:root {
  --bg: #0b1020;
  --panel: #121a2f;
  --panel2: #18233d;
  --text: #e8eefc;
  --muted: #93a0c2;
  --line: #263352;
  --accent: #5b8cff;
  --accent2: #3dd6c6;
  --danger: #ff5d6c;
  --ok: #3ecf8e;
  --warn: #f0b429;
  --radius: 16px;
  --font: "Segoe UI", "PingFang SC", "Microsoft YaHei", system-ui, sans-serif;
  --mono: ui-monospace, "Cascadia Code", Consolas, monospace;
}
* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: var(--font);
  background:
    radial-gradient(1200px 600px at 10% -10%, #1a2748 0%, transparent 50%),
    radial-gradient(900px 500px at 100% 0%, #132b3a 0%, transparent 45%),
    var(--bg);
  color: var(--text);
  min-height: 100vh;
}
.layout { max-width: 1280px; margin: 0 auto; padding: 20px; }
.top {
  display: flex; justify-content: space-between; align-items: center;
  gap: 16px; margin-bottom: 18px; flex-wrap: wrap;
}
.brand { display: flex; gap: 14px; align-items: center; }
.logo {
  width: 44px; height: 44px; border-radius: 12px;
  display: grid; place-items: center; font-weight: 800;
  background: linear-gradient(135deg, var(--accent), var(--accent2));
  color: #061018;
}
h1 { margin: 0; font-size: 1.25rem; }
.sub { margin: 2px 0 0; color: var(--muted); font-size: 0.85rem; }
.top-actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}
.card {
  background: linear-gradient(180deg, var(--panel), var(--panel2));
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px 16px 14px;
  box-shadow: 0 10px 30px rgba(0,0,0,.25);
}
.card.wide { grid-column: 1 / -1; }
.card h2 { margin: 0 0 12px; font-size: 1rem; }
.card-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.card-head h2 { margin: 0; }
.stats {
  display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; margin-bottom: 12px;
}
.stats div {
  background: rgba(255,255,255,.03); border: 1px solid var(--line);
  border-radius: 10px; padding: 10px;
}
.stats label { display: block; color: var(--muted); font-size: 0.75rem; margin-bottom: 4px; }
.stats strong { font-size: 1.05rem; word-break: break-all; }
.links { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 8px; }
.hint { color: var(--muted); font-size: 0.82rem; line-height: 1.45; margin: 8px 0 0; }
.hint code, code { font-family: var(--mono); color: #b7d0ff; }
.form { display: grid; gap: 12px; }
.form label { display: grid; gap: 6px; font-size: 0.86rem; color: var(--muted); }
.form input[type="number"],
.form input[type="text"],
.form input[type="password"],
.form input[type="url"],
.form select,
.form textarea {
  width: 100%;
  min-height: 44px;
  padding: 12px 14px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: #0c1428;
  color: var(--text);
  font-size: 15px;
  outline: none;
  transition: border-color .15s, box-shadow .15s;
}
.form input:focus,
.form select:focus,
.form textarea:focus {
  border-color: #4d7dff;
  box-shadow: 0 0 0 3px rgba(91,140,255,.18);
}
.form .check { display: flex; align-items: center; gap: 8px; color: var(--text); min-height: auto; }
.row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.btn {
  border: 1px solid var(--line); background: #162241; color: var(--text);
  border-radius: 12px; padding: 11px 16px; cursor: pointer; text-decoration: none;
  font-size: 0.92rem; display: inline-flex; align-items: center; justify-content: center;
  min-height: 42px;
}
.btn:hover { filter: brightness(1.08); }
.btn.primary {
  background: linear-gradient(135deg, #3b6ef5, #2aa8a0);
  border: none; color: white; font-weight: 600;
}
.btn.danger { background: #3a1520; border-color: #6a2434; color: #ffb4bd; }
.btn.ghost { background: transparent; }
.btn.sm { padding: 6px 10px; font-size: 0.8rem; min-height: 34px; }
.badge {
  padding: 6px 10px; border-radius: 999px; font-size: 0.8rem; border: 1px solid var(--line);
}
.badge.idle { color: var(--muted); }
.badge.run { color: #04140d; background: var(--ok); border-color: transparent; font-weight: 700; }
.badge.fail { color: #fff; background: var(--danger); border-color: transparent; }
.log {
  margin: 0; height: 360px; overflow: auto; background: #070d1a;
  border: 1px solid var(--line); border-radius: 10px; padding: 12px;
  font-family: var(--mono); font-size: 12px; line-height: 1.45; white-space: pre-wrap;
}
.table-wrap { max-height: 280px; overflow: auto; font-size: 0.86rem; }
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 8px 6px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { color: var(--muted); font-weight: 600; position: sticky; top: 0; background: var(--panel2); }
.editor {
  width: 100%; min-height: 280px; border-radius: 10px; border: 1px solid var(--line);
  background: #070d1a; color: #d6e2ff; font-family: var(--mono); font-size: 12px;
  padding: 12px; resize: vertical;
}
.hints {
  margin: 0 0 14px; padding: 12px 14px; border-radius: 12px;
  border: 1px solid #3a4d2a; background: rgba(62,207,142,.08); color: #b7f0d0;
  font-size: 0.9rem; line-height: 1.55;
}
.quick-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}
.field-full { grid-column: 1 / -1; }

/* login page */
.login-body {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}
.login-card {
  width: min(520px, 100%);
  background: linear-gradient(180deg, var(--panel), var(--panel2));
  border: 1px solid var(--line);
  border-radius: 20px;
  padding: 28px 28px 24px;
  box-shadow: 0 20px 50px rgba(0,0,0,.4);
}
.login-brand { margin-bottom: 20px; }
.login-card .form input[type="password"],
.login-card .form input[type="text"] {
  min-height: 52px;
  font-size: 16px;
  padding: 14px 16px;
  border-radius: 14px;
}
.login-card .btn.primary {
  width: 100%;
  min-height: 50px;
  font-size: 16px;
  border-radius: 14px;
}
.error { color: #ff8b97; font-size: 0.9rem; margin: 4px 0 0; }

@media (max-width: 900px) {
  .grid, .quick-grid { grid-template-columns: 1fr; }
  .stats { grid-template-columns: repeat(2, 1fr); }
  .top { flex-direction: column; align-items: flex-start; }
  .field-full { grid-column: auto; }
}

details.advanced {
  border: 1px dashed var(--line);
  border-radius: 12px;
  padding: 10px 12px;
  background: rgba(255,255,255,.02);
}
details.advanced summary {
  cursor: pointer;
  color: var(--muted);
  font-size: 0.9rem;
  user-select: none;
  text-align: left;
}
details.advanced[open] summary {
  margin-bottom: 4px;
  color: var(--text);
}

details.fold-card {
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 12px 14px;
  background: rgba(255,255,255,.02);
}
details.fold-card > summary {
  cursor: pointer;
  list-style: none;
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: 8px;
  color: var(--text);
  font-weight: 600;
  font-size: 0.95rem;
  text-align: left;
  width: 100%;
}
details.fold-card > summary::-webkit-details-marker { display: none; }
details.fold-card > summary::before {
  content: "\25B8  ";
  color: var(--muted);
  font-weight: 700;
}
details.fold-card[open] > summary::before { content: "\25BE  "; }
details.fold-card[open] > summary { margin-bottom: 10px; }
details.fold-card .hint { margin-top: 0; }

.field-key {
  display: block;
  margin-top: 2px;
  margin-bottom: 4px;
  color: #7f92c2;
  font-family: var(--mono);
  font-size: 0.75rem;
  font-weight: 500;
}
label .field-key + input,
label .field-key + select {
  margin-top: 0;
}

#toast-host {
  position: fixed;
  top: 18px;
  right: 18px;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 10px;
  max-width: min(420px, calc(100vw - 24px));
  pointer-events: none;
}
.toast-item {
  pointer-events: auto;
  padding: 12px 14px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: #121c33;
  color: var(--text);
  box-shadow: 0 12px 30px rgba(0,0,0,.35);
  font-size: 0.92rem;
  line-height: 1.4;
  animation: toast-in .18s ease-out;
}
.toast-item.ok {
  border-color: rgba(62,207,142,.45);
  background: linear-gradient(180deg, #123024, #0f1a28);
}
.toast-item.err {
  border-color: rgba(255,93,108,.5);
  background: linear-gradient(180deg, #3a1520, #1a1020);
}
.toast-item .toast-title {
  font-weight: 700;
  margin-bottom: 2px;
}
.toast-item .toast-msg {
  color: #d5def5;
  word-break: break-word;
}
@keyframes toast-in {
  from { opacity: 0; transform: translateY(-8px); }
  to { opacity: 1; transform: translateY(0); }
}
