:root {
  --bg: #f4f6f8;
  --surface: #ffffff;
  --surface-2: #f8fafc;
  --text: #18202a;
  --muted: #657487;
  --line: #dce3ea;
  --green: #3f9f5f;
  --blue: #2f80d1;
  --orange: #e88923;
  --red: #c74343;
  --purple: #7b46b3;
  --shadow: 0 12px 30px rgba(18, 32, 50, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--text);
  background: var(--bg);
  font-family: Inter, "PingFang SC", "Microsoft YaHei", Arial, sans-serif;
}

button,
input,
textarea {
  font: inherit;
}

.app-shell {
  width: min(1060px, calc(100vw - 28px));
  margin: 24px auto 48px;
}

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

.eyebrow {
  margin: 0 0 4px;
  color: var(--muted);
  font-size: 13px;
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-size: 30px;
  line-height: 1.2;
}

h2 {
  font-size: 22px;
  line-height: 1.25;
}

.config-status {
  max-width: 460px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
}

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

.tab {
  min-height: 44px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--muted);
  cursor: pointer;
}

.tab.active {
  border-color: var(--blue);
  color: var(--blue);
  background: #eef6ff;
  font-weight: 700;
}

.panel {
  display: none;
  padding: 20px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.panel.active {
  display: block;
}

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

.panel-header p {
  margin-top: 6px;
  color: var(--muted);
  line-height: 1.45;
}

.panel-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex: 0 0 auto;
}

.primary {
  min-width: 142px;
  min-height: 48px;
  border: 0;
  border-radius: 8px;
  color: white;
  cursor: pointer;
  font-weight: 700;
}

.secondary {
  min-width: 92px;
  min-height: 48px;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--muted);
  background: var(--surface-2);
  cursor: pointer;
  font-weight: 700;
}

.secondary:hover {
  border-color: var(--muted);
  color: var(--text);
}

.primary:disabled {
  cursor: not-allowed;
  opacity: 0.58;
}

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

.orange {
  background: var(--orange);
}

.purple {
  background: var(--purple);
}

.field {
  display: block;
}

.field span {
  display: block;
  margin-bottom: 8px;
  color: var(--muted);
  font-size: 14px;
}

textarea {
  width: 100%;
  min-height: 220px;
  resize: vertical;
  padding: 14px 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--text);
  background: var(--surface-2);
  line-height: 1.6;
  outline: none;
}

input[type="file"] {
  width: 100%;
  padding: 11px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--muted);
  background: var(--surface-2);
}

textarea:focus {
  border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(47, 128, 209, 0.14);
}

.config-block {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 142px;
  gap: 12px;
  align-items: end;
  margin-bottom: 18px;
}

.config-block .progress-line {
  grid-column: 1 / -1;
  margin: 0;
}

.progress-line {
  margin: 16px 0;
  min-height: 24px;
  color: var(--muted);
  line-height: 1.5;
}

.results {
  display: grid;
  gap: 10px;
}

.status-results {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  overflow: hidden;
}

.status-results:empty {
  display: none;
}

.status-row {
  padding: 14px 18px;
  border-bottom: 1px solid var(--line);
  font-size: 17px;
  font-weight: 700;
  line-height: 1.7;
  word-break: break-word;
}

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

.status-row.success {
  color: #247343;
}

.status-row.warning,
.status-row.error {
  color: var(--red);
}

.result-card {
  padding: 14px;
  border: 1px solid var(--line);
  border-left: 5px solid var(--blue);
  border-radius: 8px;
  background: var(--surface);
}

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

.result-card.warning {
  border-left-color: var(--orange);
}

.result-title {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 8px;
  font-weight: 800;
}

.badge {
  flex: 0 0 auto;
  padding: 3px 8px;
  border-radius: 999px;
  background: #e8f5ee;
  color: #247343;
  font-size: 12px;
}

.badge.error {
  background: #fff0f0;
  color: var(--red);
}

.badge.warning {
  background: #fff5e7;
  color: #9a540f;
}

.meta {
  color: var(--muted);
  font-size: 14px;
  line-height: 1.7;
}

.state-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 10px;
}

.state-pill {
  padding: 6px 9px;
  border-radius: 8px;
  background: var(--surface-2);
  border: 1px solid var(--line);
  font-size: 13px;
}

.state-button {
  cursor: pointer;
  font-weight: 700;
}

.state-button:hover {
  filter: brightness(0.98);
}

.state-online {
  color: #247343;
  border-color: #cfe8d8;
  background: #f1faf4;
}

.state-offline {
  color: var(--red);
  border-color: #f0caca;
  background: #fff5f5;
}

.state-los {
  color: #9a540f;
  border-color: #f0d3a9;
  background: #fff8ef;
}

.state-other,
.state-unknown {
  color: var(--purple);
  border-color: #dccded;
  background: #f8f2ff;
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: rgba(24, 32, 42, 0.44);
}

.modal {
  width: min(520px, 100%);
  max-height: min(78vh, 680px);
  overflow: auto;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

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

.modal-title {
  margin: 0;
  font-size: 20px;
  line-height: 1.3;
}

.modal-close {
  width: 36px;
  height: 36px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-2);
  color: var(--muted);
  cursor: pointer;
  font-size: 24px;
  line-height: 1;
}

.modal-close:hover {
  color: var(--text);
  border-color: var(--muted);
}

.modal-summary {
  margin: 0 0 12px;
  color: var(--muted);
  line-height: 1.5;
}

.offline-list {
  display: grid;
  gap: 8px;
  margin: 0;
  padding-left: 22px;
}

.offline-list li {
  padding: 8px 0;
  border-bottom: 1px solid var(--line);
  line-height: 1.5;
}

.offline-list li:last-child {
  border-bottom: 0;
}

.offline-list small {
  display: block;
  margin-top: 2px;
  color: var(--muted);
  font-size: 12px;
}

@media (max-width: 720px) {
  .app-shell {
    width: min(100vw - 20px, 680px);
    margin-top: 12px;
  }

  .topbar,
  .panel-header {
    display: block;
  }

  .panel-actions {
    display: grid;
    grid-template-columns: 1fr;
    margin-top: 14px;
  }

  .config-status {
    margin-top: 12px;
    max-width: none;
  }

  .primary {
    width: 100%;
    margin-top: 14px;
  }

  .panel-actions .primary,
  .panel-actions .secondary {
    width: 100%;
    margin-top: 0;
  }

  .config-block {
    display: block;
  }

  textarea {
    min-height: 240px;
  }
}
