:root {
  color-scheme: light;
  --bg: #eef2f6;
  --surface: #ffffff;
  --text: #18212f;
  --muted: #647184;
  --line: #d9e0e8;
  --accent: #146c94;
  --accent-dark: #0f536f;
  --success: #178047;
  --warning: #a36200;
  --danger: #b42318;
  --shadow: 0 18px 50px rgba(24, 33, 47, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: linear-gradient(180deg, #f7f9fb 0%, var(--bg) 100%);
  color: var(--text);
  font-family: "Microsoft YaHei", "Segoe UI", system-ui, sans-serif;
}

button,
input,
select {
  font: inherit;
}

button {
  height: 40px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #ffffff;
  color: var(--text);
  cursor: pointer;
  transition: border-color 0.15s ease, background 0.15s ease, transform 0.15s ease;
}

button:hover {
  border-color: #aab8c8;
  background: #f8fafc;
}

button:active {
  transform: translateY(1px);
}

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

input,
select {
  width: 100%;
  height: 42px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #ffffff;
  color: var(--text);
  padding: 0 12px;
  outline: none;
}

input:focus,
select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(20, 108, 148, 0.12);
}

label span {
  display: block;
  margin-bottom: 7px;
  color: var(--muted);
  font-size: 13px;
}

.shell {
  width: min(1120px, calc(100vw - 32px));
  margin: 28px auto 56px;
}

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

.eyebrow {
  margin: 0 0 6px;
  color: var(--accent);
  font-size: 13px;
  font-weight: 700;
}

h1 {
  margin: 0;
  font-size: clamp(26px, 4vw, 38px);
  line-height: 1.1;
  letter-spacing: 0;
}

.top-actions {
  display: flex;
  gap: 10px;
}

.icon-button {
  width: 42px;
  padding: 0;
  font-size: 20px;
}

.primary-button {
  min-width: 96px;
  border-color: var(--accent);
  background: var(--accent);
  color: #ffffff;
  font-weight: 700;
}

.primary-button:hover {
  border-color: var(--accent-dark);
  background: var(--accent-dark);
}

.status-line {
  display: flex;
  align-items: center;
  min-height: 26px;
  gap: 9px;
  margin-bottom: 14px;
  color: var(--muted);
  font-size: 14px;
}

.dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: #8b98a8;
}

.dot.ok {
  background: var(--success);
}

.dot.warn {
  background: var(--warning);
}

.dot.bad {
  background: var(--danger);
}

.endpoint-panel,
.settings-grid,
.toolbar,
.source-item {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.endpoint-panel {
  padding: 18px;
  margin-bottom: 14px;
}

.endpoint-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 86px 86px;
  gap: 10px;
}

.settings-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
  padding: 18px;
  margin-bottom: 14px;
}

.toolbar {
  display: flex;
  gap: 10px;
  padding: 12px;
  margin-bottom: 14px;
}

.toolbar button {
  min-width: 106px;
}

.source-list {
  display: grid;
  gap: 12px;
}

.source-item {
  display: grid;
  grid-template-columns: 76px minmax(0, 1fr) 272px;
  gap: 14px;
  align-items: start;
  padding: 16px;
}

.source-meta {
  display: grid;
  justify-items: center;
  gap: 10px;
}

.source-index {
  width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 50%;
  color: var(--muted);
  font-weight: 700;
}

.switch {
  display: inline-flex;
  align-items: center;
  height: 32px;
  cursor: pointer;
}

.switch input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.switch span {
  width: 48px;
  height: 28px;
  margin: 0;
  border-radius: 999px;
  background: #c8d1dc;
  position: relative;
  transition: background 0.15s ease;
}

.switch span::after {
  content: "";
  position: absolute;
  top: 4px;
  left: 4px;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: #ffffff;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.2);
  transition: transform 0.15s ease;
}

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

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

.source-fields {
  display: grid;
  gap: 12px;
}

.source-actions {
  display: grid;
  grid-template-columns: 44px 44px 1fr 1fr;
  gap: 8px;
}

.source-actions button {
  padding: 0 10px;
}

.danger {
  color: var(--danger);
}

.danger:hover {
  border-color: rgba(180, 35, 24, 0.5);
  background: #fff7f6;
}

.source-result {
  grid-column: 2 / 4;
  min-height: 22px;
  color: var(--muted);
  font-size: 13px;
}

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

.source-result.bad {
  color: var(--danger);
}

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

  .top-actions,
  .endpoint-row,
  .settings-grid {
    grid-template-columns: 1fr;
  }

  .top-actions {
    display: grid;
    grid-template-columns: 44px 1fr;
  }

  .source-item {
    grid-template-columns: 1fr;
  }

  .source-meta {
    grid-template-columns: auto 1fr;
    justify-items: start;
  }

  .source-actions {
    grid-template-columns: 44px 44px minmax(74px, 1fr) minmax(74px, 1fr);
  }

  .source-result {
    grid-column: 1;
  }
}
