:root {
  color-scheme: light;
  --bg: #f6f7fb;
  --surface: #ffffff;
  --surface-soft: #f1f3f9;
  --line: #e3e7ef;
  --line-strong: #cdd4e0;
  --text: #0f172a;
  --muted: #5b6577;
  --accent: #2563eb;
  --accent-strong: #1d4ed8;
  --accent-soft: #e0e9ff;
  --success: #15803d;
  --success-soft: #dcfce7;
  --danger: #b91c1c;
  --danger-soft: #fee2e2;
  --warning: #b45309;
  --warning-soft: #fef3c7;
  --shadow-sm: 0 1px 2px rgba(15, 23, 42, 0.06);
  --shadow-md: 0 10px 30px rgba(15, 23, 42, 0.08);
  --radius: 12px;
  --radius-sm: 8px;
  --mono: ui-monospace, SFMono-Regular, "SF Mono", Consolas, "Liberation Mono", Menlo, monospace;
  --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", "Inter", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei UI", sans-serif;
}

@media (prefers-color-scheme: dark) {
  :root {
    color-scheme: dark;
    --bg: #0b1020;
    --surface: #11182b;
    --surface-soft: #161f36;
    --line: #1f2a44;
    --line-strong: #2c3a5d;
    --text: #e5e9f2;
    --muted: #94a0b8;
    --accent: #6ea8ff;
    --accent-strong: #4c8bff;
    --accent-soft: rgba(110, 168, 255, 0.12);
    --success: #4ade80;
    --success-soft: rgba(74, 222, 128, 0.12);
    --danger: #f87171;
    --danger-soft: rgba(248, 113, 113, 0.12);
    --warning: #fbbf24;
    --warning-soft: rgba(251, 191, 36, 0.12);
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.3);
    --shadow-md: 0 16px 40px rgba(0, 0, 0, 0.5);
  }
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body {
  font-family: var(--sans);
  color: var(--text);
  background:
    radial-gradient(1200px 600px at 12% -10%, rgba(37, 99, 235, 0.12), transparent 60%),
    radial-gradient(900px 500px at 110% 0%, rgba(99, 102, 241, 0.10), transparent 60%),
    var(--bg);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  font-size: 14.5px;
  line-height: 1.55;
}

button, input, textarea, select { font: inherit; color: inherit; }
button { border: 0; cursor: pointer; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

.app {
  width: min(1080px, calc(100vw - 28px));
  margin: 0 auto;
  padding: 28px 0 48px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 24px;
}
.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}
.brand-mark {
  width: 36px; height: 36px;
  border-radius: 10px;
  background: linear-gradient(135deg, var(--accent), #6366f1);
  display: grid; place-items: center;
  color: #fff; font-weight: 800; font-size: 17px;
  box-shadow: 0 6px 16px rgba(37, 99, 235, 0.30);
}
.brand-title { display: flex; flex-direction: column; min-width: 0; }
.brand-title .eyebrow {
  color: var(--muted);
  font-size: 11px; letter-spacing: 0.16em; text-transform: uppercase; font-weight: 700;
}
.brand-title h1 {
  margin: 2px 0 0; font-size: 18px; font-weight: 700;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.topbar .actions { display: flex; gap: 8px; }

.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
}
.card + .card { margin-top: 16px; }
.card-header {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 16px 18px; border-bottom: 1px solid var(--line);
}
.card-header h2 { margin: 0; font-size: 15px; font-weight: 700; }
.card-header .hint { color: var(--muted); font-size: 12.5px; }
.card-body { padding: 18px; }
.card-body + .card-body { border-top: 1px solid var(--line); }

.notice {
  border-radius: var(--radius-sm);
  border: 1px solid var(--line);
  background: var(--surface-soft);
  padding: 12px 14px;
  color: var(--text);
  font-size: 13.5px;
  line-height: 1.6;
  white-space: pre-line;
}
.notice strong { color: var(--accent); }

.stack { display: flex; flex-direction: column; gap: 12px; }
.row { display: flex; gap: 10px; align-items: stretch; flex-wrap: wrap; }
.row > * { flex: 1 1 0; min-width: 0; }

input[type="text"], textarea {
  width: 100%;
  padding: 11px 14px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--line-strong);
  background: var(--surface);
  color: var(--text);
  transition: border-color .15s, box-shadow .15s, background-color .15s;
  outline: none;
}
input[type="text"]:focus, textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}
textarea { min-height: 160px; resize: vertical; font-family: var(--mono); font-size: 13px; }

.btn {
  display: inline-flex; align-items: center; justify-content: center;
  gap: 6px;
  min-height: 40px; padding: 0 16px;
  border-radius: var(--radius-sm);
  background: var(--accent); color: #fff; font-weight: 600;
  transition: filter .15s, transform .03s, background-color .15s, color .15s;
  white-space: nowrap;
}
.btn:hover { filter: brightness(1.05); }
.btn:active { transform: translateY(1px); }
.btn[disabled] { opacity: .6; cursor: not-allowed; }

.btn-ghost {
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--line-strong);
}
.btn-ghost:hover { background: var(--surface-soft); }

.btn-soft {
  background: var(--accent-soft);
  color: var(--accent-strong);
}
.btn-soft:hover { filter: brightness(0.98); }

.btn-danger { background: var(--danger); }

.stat-grid {
  display: grid; gap: 12px;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
}
.stat {
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--surface-soft);
  padding: 14px;
}
.stat .k { color: var(--muted); font-size: 12px; font-weight: 600; letter-spacing: 0.04em; text-transform: uppercase; }
.stat .v { font-size: 22px; font-weight: 700; margin-top: 4px; }

.tabs {
  display: inline-flex;
  padding: 4px;
  background: var(--surface-soft);
  border: 1px solid var(--line);
  border-radius: 999px;
  gap: 4px;
}
.tabs button {
  background: transparent;
  color: var(--muted);
  padding: 6px 14px;
  border-radius: 999px;
  font-weight: 600;
  font-size: 13px;
}
.tabs button[aria-pressed="true"] {
  background: var(--surface);
  color: var(--text);
  box-shadow: var(--shadow-sm);
}

.status-pill {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
  border: 1px solid var(--line);
  background: var(--surface-soft);
  color: var(--muted);
}
.status-pill.ok { background: var(--success-soft); border-color: transparent; color: var(--success); }
.status-pill.err { background: var(--danger-soft); border-color: transparent; color: var(--danger); }
.status-pill.warn { background: var(--warning-soft); border-color: transparent; color: var(--warning); }

.kvlist { display: grid; gap: 10px; }
.kv { display: grid; grid-template-columns: 130px 1fr auto; gap: 10px; align-items: center; }
.kv .k { color: var(--muted); font-size: 13px; }
.kv .v {
  font-family: var(--mono); font-size: 12.8px;
  background: var(--surface-soft);
  border: 1px solid var(--line);
  padding: 8px 10px;
  border-radius: 8px;
  word-break: break-all;
  white-space: pre-wrap;
  user-select: all;
}

.muted { color: var(--muted); }
.hide { display: none !important; }

.loading {
  display: inline-block;
  width: 14px; height: 14px;
  border: 2px solid currentColor;
  border-top-color: transparent;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  vertical-align: -2px;
  margin-right: 6px;
}
@keyframes spin { to { transform: rotate(360deg); } }

footer {
  margin-top: 26px;
  color: var(--muted);
  font-size: 12px;
  text-align: center;
}

@media (max-width: 640px) {
  .kv { grid-template-columns: 1fr; }
  .kv .copy { justify-self: end; }
  .row > * { flex-basis: 100%; }
}
