:root {
  color-scheme: light;
  --bg: #f5f7fb;
  --surface: #ffffff;
  --surface-soft: #eef4f2;
  --ink: #18212f;
  --muted: #647184;
  --line: #dce3ec;
  --primary: #116b5f;
  --primary-dark: #0d5149;
  --accent: #b7791f;
  --danger: #b42318;
  --success: #067647;
  --shadow: 0 18px 45px rgba(23, 35, 54, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-width: 320px;
  background: var(--bg);
  color: var(--ink);
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    "PingFang SC", "Microsoft YaHei", sans-serif;
}

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

button {
  cursor: pointer;
}

.app-shell {
  width: min(1440px, 100%);
  margin: 0 auto;
  padding: 24px;
}

.topbar {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(280px, 460px);
  gap: 24px;
  align-items: end;
  padding: 16px 0 20px;
}

.eyebrow {
  margin: 0 0 6px;
  color: var(--primary);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1,
h2 {
  margin: 0;
  letter-spacing: 0;
}

h1 {
  font-size: clamp(28px, 4vw, 44px);
  line-height: 1.08;
}

h2 {
  font-size: 20px;
}

.api-box label,
.form label span {
  display: block;
  margin-bottom: 7px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.api-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
}

input,
select,
textarea {
  width: 100%;
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  padding: 9px 11px;
  outline: none;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(17, 107, 95, 0.14);
}

textarea {
  line-height: 1.65;
  resize: vertical;
}

.tabs {
  display: flex;
  gap: 8px;
  margin-bottom: 18px;
  border-bottom: 1px solid var(--line);
  overflow-x: auto;
}

.tab {
  min-height: 44px;
  border: 0;
  border-bottom: 3px solid transparent;
  background: transparent;
  color: var(--muted);
  padding: 8px 16px 11px;
  font-weight: 800;
  white-space: nowrap;
}

.tab.active {
  border-color: var(--primary);
  color: var(--primary);
}

.view {
  display: none;
}

.active-view {
  display: block;
}

.section-grid {
  display: grid;
  grid-template-columns: minmax(360px, 0.9fr) minmax(560px, 1.1fr);
  gap: 18px;
  align-items: start;
}

.monitor-grid {
  display: grid;
  grid-template-columns: minmax(280px, 380px) minmax(0, 1fr);
  gap: 18px;
  align-items: start;
}

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

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

.button {
  min-height: 40px;
  border: 1px solid var(--primary);
  border-radius: 8px;
  background: #fff;
  color: var(--primary);
  padding: 8px 14px;
  font-weight: 800;
}

.button:hover {
  background: var(--surface-soft);
}

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

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

.button.ghost {
  border-color: var(--line);
  color: var(--ink);
}

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

.icon-button {
  display: inline-grid;
  width: 38px;
  height: 38px;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  font-size: 24px;
  line-height: 1;
}

.form {
  display: grid;
  gap: 16px;
}

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

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

.numeric-grid {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.advanced {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
  background: #fbfcfe;
}

.advanced-title {
  margin-bottom: 12px;
  color: var(--ink);
  font-weight: 900;
}

.form-actions,
.filters {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}

.filters {
  justify-content: flex-end;
}

.filters select {
  min-width: 220px;
}

.switch {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  font-weight: 800;
}

.switch input {
  width: 18px;
  min-height: 18px;
}

.table-wrap {
  overflow-x: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
  min-width: 760px;
}

th,
td {
  border-bottom: 1px solid var(--line);
  padding: 13px 10px;
  text-align: left;
  vertical-align: top;
}

th {
  color: var(--muted);
  font-size: 12px;
  font-weight: 900;
}

td {
  font-size: 14px;
}

.url-cell,
.selector-cell,
.muted {
  color: var(--muted);
}

.url-cell,
.selector-cell {
  max-width: 260px;
  overflow-wrap: anywhere;
}

.pill {
  display: inline-flex;
  align-items: center;
  min-height: 26px;
  border-radius: 999px;
  padding: 3px 9px;
  background: var(--surface-soft);
  color: var(--primary);
  font-size: 12px;
  font-weight: 900;
}

.pill.off {
  background: #f7e8e7;
  color: var(--danger);
}

.results-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(290px, 1fr));
  gap: 14px;
}

.result-card {
  min-height: 230px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  padding: 16px;
}

.result-card h3 {
  margin: 8px 0 10px;
  font-size: 18px;
  line-height: 1.35;
}

.title-button {
  border: 0;
  background: transparent;
  color: var(--ink);
  padding: 0;
  text-align: left;
  font-weight: 900;
}

.title-button:hover {
  color: var(--primary);
  text-decoration: underline;
}

.result-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  color: var(--muted);
  font-size: 13px;
}

.result-summary {
  margin: 12px 0 0;
  color: #334155;
  line-height: 1.65;
}

.empty-state {
  border: 1px dashed var(--line);
  border-radius: 8px;
  padding: 24px;
  color: var(--muted);
  text-align: center;
}

.status-panel {
  display: grid;
  gap: 18px;
}

.status-badge {
  display: grid;
  min-height: 118px;
  place-items: center;
  border-radius: 8px;
  background: #e8f5ef;
  color: var(--success);
  font-size: 34px;
  font-weight: 950;
}

.status-badge.running {
  background: #fff4df;
  color: var(--accent);
}

.status-badge.failed {
  background: #fbe9e8;
  color: var(--danger);
}

.status-meta {
  display: grid;
  gap: 10px;
  margin: 0;
}

.status-meta div,
.run-row {
  display: grid;
  grid-template-columns: 90px minmax(0, 1fr);
  gap: 12px;
  align-items: start;
}

dt {
  color: var(--muted);
  font-weight: 800;
}

dd {
  margin: 0;
  overflow-wrap: anywhere;
}

.runs-list {
  display: grid;
  gap: 10px;
}

.run-row {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  background: #fff;
}

.run-row strong {
  overflow-wrap: anywhere;
}

.settings-panel {
  max-width: 980px;
}

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

.tool-card h3 {
  margin: 0 0 7px;
  font-size: 16px;
}

.tool-card p {
  margin: 0;
  color: var(--muted);
  line-height: 1.6;
}

.detail-dialog {
  width: min(860px, calc(100vw - 24px));
  max-height: 88vh;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0;
  box-shadow: var(--shadow);
}

.detail-dialog::backdrop {
  background: rgba(15, 23, 42, 0.48);
}

.detail-dialog article {
  padding: 20px;
}

.dialog-head {
  display: flex;
  gap: 14px;
  justify-content: space-between;
  align-items: start;
}

.dialog-head h2 {
  line-height: 1.35;
}

.dialog-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin: 12px 0;
  color: var(--muted);
}

.dialog-meta a {
  color: var(--primary);
  font-weight: 800;
}

.summary-box {
  margin: 14px 0;
  border-left: 4px solid var(--primary);
  background: var(--surface-soft);
  padding: 12px;
  color: #25413d;
  line-height: 1.65;
}

pre {
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  margin: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfe;
  padding: 14px;
  color: #273244;
  font-family: inherit;
  line-height: 1.75;
}

.output-box {
  margin-top: 16px;
}

.toast {
  position: fixed;
  right: 20px;
  bottom: 20px;
  max-width: min(420px, calc(100vw - 40px));
  transform: translateY(120%);
  border-radius: 8px;
  background: #111827;
  color: #fff;
  padding: 12px 14px;
  box-shadow: var(--shadow);
  opacity: 0;
  transition:
    opacity 0.18s ease,
    transform 0.18s ease;
  z-index: 20;
}

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

@media (max-width: 1120px) {
  .section-grid,
  .monitor-grid,
  .topbar {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 760px) {
  .app-shell {
    padding: 14px;
  }

  .panel {
    padding: 14px;
  }

  .panel-head,
  .results-head {
    align-items: stretch;
    flex-direction: column;
  }

  .field-grid,
  .selectors,
  .numeric-grid,
  .api-row {
    grid-template-columns: 1fr;
  }

  .button {
    width: 100%;
  }

  .filters,
  .form-actions {
    width: 100%;
  }

  .filters select {
    min-width: 0;
  }
}
