:root {
  --bg: #eef2f6;
  --surface: #ffffff;
  --surface-soft: #f7f9fb;
  --line: #d8e0e8;
  --text: #17202a;
  --muted: #667085;
  --blue: #1769e0;
  --blue-soft: #e8f1ff;
  --green: #12805c;
  --red: #bf2f2f;
  --amber: #a66a00;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Arial, sans-serif;
}

.shell {
  width: min(1180px, 100%);
  margin: 0 auto;
  padding: 18px 14px 42px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 10px 2px 14px;
}

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

h1 {
  font-size: 24px;
  font-weight: 760;
}

h2 {
  font-size: 17px;
  margin-bottom: 14px;
}

h3 {
  font-size: 14px;
  margin: 2px 0 10px;
}

#subtitle,
.hint {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
}

.status-pill {
  min-width: 92px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface);
  padding: 8px 12px;
  color: var(--muted);
  text-align: center;
  font-weight: 700;
}

.status-pill.ok {
  color: var(--green);
  border-color: #b7dfcf;
  background: #eefaf5;
}

.status-pill.bad {
  color: var(--red);
  border-color: #efc4c4;
  background: #fff2f2;
}

.status-pill.warn {
  color: var(--amber);
  border-color: #efd6a4;
  background: #fff8e8;
}

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

.connect-panel {
  margin-bottom: 12px;
}

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

label {
  display: grid;
  gap: 6px;
  color: #344054;
  font-size: 13px;
  font-weight: 680;
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid #c8d2dc;
  border-radius: 8px;
  background: #fff;
  color: var(--text);
  padding: 10px 11px;
  font: inherit;
  outline: 0;
}

textarea {
  min-height: 112px;
  resize: vertical;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(23, 105, 224, 0.12);
}

.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 12px;
}

.actions.tight {
  margin-top: 0;
}

button {
  border: 0;
  border-radius: 8px;
  background: var(--blue);
  color: #fff;
  padding: 10px 13px;
  font: inherit;
  font-weight: 700;
  cursor: pointer;
}

button.secondary {
  background: #e9eef5;
  color: #1f2937;
}

button.danger {
  background: var(--red);
}

button:disabled {
  opacity: 0.48;
  cursor: not-allowed;
}

.tabs {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
  margin: 12px 0;
}

.tabs button {
  background: var(--surface);
  color: #495565;
  border: 1px solid var(--line);
}

.tabs button.active {
  background: var(--blue-soft);
  color: var(--blue);
  border-color: #bad3ff;
}

.tab {
  display: none;
}

.tab.active {
  display: block;
}

.hidden {
  display: none;
}

.metrics {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 12px;
}

.metric {
  min-height: 78px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
}

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

.metric strong {
  display: block;
  margin-top: 8px;
  font-size: 17px;
  word-break: break-word;
}

.two-col {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 12px;
}

.kv {
  display: grid;
}

.row {
  display: flex;
  justify-content: space-between;
  gap: 14px;
  border-bottom: 1px solid #edf1f5;
  padding: 10px 0;
}

.row:last-child {
  border-bottom: 0;
}

.row span:first-child {
  color: var(--muted);
}

.row span:last-child {
  text-align: right;
  word-break: break-all;
}

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

.config-form {
  display: grid;
  gap: 14px;
  margin-top: 14px;
}

.config-section {
  border: 1px solid var(--line);
  background: var(--surface-soft);
  border-radius: 8px;
  padding: 12px;
}

.switch-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding-top: 22px;
}

.switch-row input {
  width: auto;
}

.log {
  min-height: 190px;
  max-height: 360px;
  overflow: auto;
  border-radius: 8px;
  background: #0f172a;
  color: #d6f7df;
  padding: 12px;
  white-space: pre-wrap;
  word-break: break-word;
  font-size: 12px;
}

.toast {
  position: fixed;
  left: 16px;
  right: 16px;
  bottom: 16px;
  max-width: 720px;
  margin: 0 auto;
  background: #111827;
  color: #fff;
  border-radius: 8px;
  padding: 12px 14px;
  opacity: 0;
  pointer-events: none;
  transform: translateY(10px);
  transition: 160ms ease;
}

.toast.show {
  opacity: 1;
  transform: translateY(0);
}

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

.warn-text {
  color: var(--amber);
}

.bad-text {
  color: var(--red);
}

@media (max-width: 820px) {
  .topbar,
  .panel-head {
    align-items: stretch;
    flex-direction: column;
  }

  .form-grid,
  .config-grid,
  .two-col,
  .metrics {
    grid-template-columns: 1fr;
  }

  .tabs {
    grid-template-columns: repeat(2, 1fr);
  }
}
