:root {
  --bg: #eef3f8;
  --panel: #ffffff;
  --line: #d8e1ec;
  --ink: #0f172a;
  --muted: #64748b;
  --blue: #2563eb;
  --orange: #f0a31e;
  --green: #16a34a;
  --red: #dc2626;
  font-family: Inter, "Microsoft YaHei", system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

html,
body {
  width: 100%;
  min-height: 100%;
  margin: 0;
}

body {
  background: var(--bg);
  color: var(--ink);
}

a {
  color: inherit;
  text-decoration: none;
}

button,
input,
select,
textarea {
  font: inherit;
}

.shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 220px minmax(0, 1fr);
}

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  border-right: 1px solid var(--line);
  background: #fff;
  padding: 16px 12px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 18px;
}

.brand-mark {
  display: inline-grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border-radius: 8px;
  background: var(--blue);
  color: #fff;
  font-weight: 900;
}

.brand strong,
.brand small {
  display: block;
}

.brand small {
  color: var(--muted);
  font-size: 12px;
}

.nav {
  width: 100%;
  min-height: 38px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: #334155;
  display: flex;
  align-items: center;
  padding: 0 12px;
  margin-bottom: 6px;
  cursor: pointer;
}

.nav:hover,
.nav.active {
  background: #dbeafe;
  color: var(--blue);
}

.nav.muted {
  margin-top: 20px;
  color: var(--muted);
}

.main {
  min-width: 0;
  padding: 22px;
}

.topbar {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: center;
  margin-bottom: 18px;
}

.eyebrow {
  margin: 0 0 4px;
  color: var(--muted);
  font-size: 12px;
  text-transform: uppercase;
}

h1,
h2,
h3,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 0;
  font-size: 26px;
}

.status {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: #334155;
}

.dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: #94a3b8;
}

.dot.online {
  background: var(--green);
}

.dot.offline {
  background: var(--red);
}

.view {
  display: grid;
  gap: 14px;
}

.panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  padding: 16px;
}

.hero,
.panel-head,
.card-head,
.actions {
  display: flex;
  justify-content: space-between;
  gap: 14px;
  align-items: flex-start;
}

.hero p,
.card-head p,
.docs p {
  color: var(--muted);
  line-height: 1.58;
}

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 34px;
  border-radius: 8px;
  padding: 0 13px;
  border: 1px solid var(--line);
  background: #fff;
  color: #334155;
  cursor: pointer;
}

.button.primary {
  border-color: var(--blue);
  background: var(--blue);
  color: #fff;
}

.button.secondary {
  background: #f8fafc;
}

.button.link {
  color: var(--blue);
}

.platform-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(420px, 1fr));
  gap: 14px;
}

.platform-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  padding: 15px;
}

.platform-card h3 {
  margin-bottom: 5px;
  font-size: 17px;
}

.mode-pill {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  margin-top: 2px;
  border: 1px solid #bfdbfe;
  border-radius: 999px;
  padding: 0 9px;
  background: #eff6ff;
  color: #1d4ed8;
  font-size: 12px;
  font-weight: 800;
}

.setup-list {
  margin: 0 0 12px;
  padding-left: 18px;
  color: #475569;
  font-size: 12px;
  line-height: 1.58;
}

.setup-list li + li {
  margin-top: 3px;
}

.bind-choice {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  margin: 0 0 12px;
}

.bind-choice > div {
  border: 1px solid #dbe7f3;
  border-radius: 8px;
  background: #f8fafc;
  padding: 10px;
}

.bind-choice strong {
  display: block;
  margin-bottom: 5px;
  font-size: 13px;
}

.bind-choice p {
  margin: 0 0 8px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.5;
}

.switch {
  flex: 0 0 auto;
  position: relative;
  display: inline-flex;
  width: 42px;
  height: 24px;
}

.switch input {
  position: absolute;
  opacity: 0;
}

.switch span {
  width: 100%;
  border-radius: 999px;
  background: #cbd5e1;
}

.switch span::after {
  content: "";
  position: absolute;
  top: 3px;
  left: 3px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 1px 4px rgba(15, 23, 42, 0.24);
  transition: transform 0.15s ease;
}

.switch input:checked + span {
  background: var(--green);
}

.switch input:checked + span::after {
  transform: translateX(18px);
}

.badge {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  border-radius: 999px;
  padding: 0 10px;
  margin: 8px 0 12px;
  font-size: 12px;
  font-weight: 800;
}

.badge.ok {
  background: #dcfce7;
  color: #166534;
}

.badge.todo {
  background: #eef2ff;
  color: #304f9f;
}

.runtime-badge {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  max-width: 100%;
  min-height: 26px;
  margin: -4px 0 12px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #f8fafc;
  color: #475569;
  padding: 0 10px;
  font-size: 12px;
}

.runtime-badge span {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #94a3b8;
  flex: 0 0 auto;
}

.runtime-badge strong {
  white-space: nowrap;
}

.runtime-badge em {
  min-width: 0;
  max-width: 360px;
  overflow: hidden;
  color: var(--muted);
  font-style: normal;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.runtime-badge.online {
  border-color: #bbf7d0;
  background: #f0fdf4;
  color: #166534;
}

.runtime-badge.online span {
  background: var(--green);
}

.runtime-badge.configured {
  border-color: #bfdbfe;
  background: #eff6ff;
  color: #1d4ed8;
}

.runtime-badge.configured span {
  background: var(--blue);
}

.runtime-badge.error {
  border-color: #fecaca;
  background: #fef2f2;
  color: #b91c1c;
}

.runtime-badge.error span {
  background: var(--red);
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 9px;
}

.field-wide {
  grid-column: 1 / -1;
}

.field {
  display: grid;
  gap: 5px;
  margin-bottom: 10px;
  color: #334155;
  font-size: 12px;
  font-weight: 700;
}

.field em {
  margin-left: 3px;
  color: var(--red);
  font-style: normal;
}

.field input,
.field select,
.field textarea {
  width: 100%;
  min-height: 34px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  padding: 8px 10px;
  font-size: 12px;
  font-weight: 400;
  outline: none;
}

.field textarea {
  resize: vertical;
}

.field input:focus,
.field select:focus,
.field textarea:focus {
  border-color: var(--orange);
}

.route-box {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8fafc;
  padding: 12px;
  margin: 12px 0;
}

.agent-checks {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 8px;
}

.check {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: #334155;
  font-size: 12px;
}

.actions {
  justify-content: flex-start;
  flex-wrap: wrap;
  align-items: center;
}

.runtime-actions {
  margin-top: 8px;
}

.result {
  min-height: 22px;
  margin: 10px 0 0;
  color: var(--muted);
  font-size: 12px;
}

.result.ok {
  color: var(--green);
}

.result.error {
  color: var(--red);
}

.result a {
  color: var(--blue);
  text-decoration: underline;
}

.diagnostics {
  display: grid;
  gap: 6px;
  width: 100%;
  margin-top: 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8fafc;
  padding: 10px;
  color: #334155;
}

.diagnostics-head,
.diagnostic-row {
  display: grid;
  grid-template-columns: minmax(120px, 0.4fr) minmax(0, 1fr);
  gap: 10px;
  align-items: start;
}

.diagnostics-head {
  padding-bottom: 5px;
  border-bottom: 1px solid var(--line);
  font-size: 12px;
}

.diagnostics-head span {
  justify-self: end;
  font-weight: 800;
}

.diagnostic-row {
  font-size: 12px;
}

.diagnostic-row b {
  color: #0f172a;
}

.diagnostic-row em {
  color: var(--muted);
  font-style: normal;
  word-break: break-word;
}

.diagnostic-row.ok b {
  color: var(--green);
}

.diagnostic-row.warn b {
  color: #b45309;
}

.diagnostic-row.error b {
  color: var(--red);
}

.record-list {
  display: grid;
  gap: 8px;
}

.record {
  display: grid;
  gap: 4px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8fafc;
  padding: 10px 12px;
}

.record span {
  color: #334155;
  word-break: break-word;
}

.record small,
.empty {
  color: var(--muted);
}

.docs code {
  border-radius: 6px;
  background: #eef2ff;
  color: #304f9f;
  padding: 2px 6px;
}

.login {
  display: grid;
  place-items: center;
  min-height: 60vh;
}

.login-card {
  width: min(420px, 100%);
}

@media (max-width: 900px) {
  .shell {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: static;
    height: auto;
  }

  .platform-grid,
  .form-grid {
    grid-template-columns: 1fr;
  }
}
