:root {
  color-scheme: light;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: #f4f7f8;
  color: #172026;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
}

button {
  border: 1px solid #b9c6cd;
  border-radius: 6px;
  background: #ffffff;
  color: #172026;
  cursor: pointer;
  font: inherit;
  min-height: 36px;
  padding: 0 14px;
}

input,
select {
  border: 1px solid #b9c6cd;
  border-radius: 6px;
  font: inherit;
  min-height: 36px;
  padding: 6px 10px;
  width: 100%;
}

button:hover {
  border-color: #4c7d8f;
}

.topbar {
  align-items: center;
  background: #ffffff;
  border-bottom: 1px solid #d7e0e4;
  display: flex;
  gap: 24px;
  justify-content: space-between;
  padding: 20px clamp(16px, 4vw, 44px);
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-size: clamp(24px, 4vw, 38px);
  font-weight: 750;
}

h2 {
  font-size: 18px;
}

#health,
#run-status {
  color: #5b6970;
  margin-top: 6px;
}

main {
  padding: 22px clamp(16px, 4vw, 44px) 44px;
}

.builder {
  background: #ffffff;
  border: 1px solid #d7e0e4;
  border-radius: 8px;
  margin-bottom: 22px;
  padding: 16px;
}

.builder-grid {
  display: grid;
  gap: 12px;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  margin-top: 14px;
}

label {
  color: #415059;
  display: grid;
  font-size: 13px;
  gap: 5px;
}

fieldset {
  border: 1px solid #d7e0e4;
  border-radius: 8px;
  display: grid;
  gap: 6px;
  grid-column: 1 / -1;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  margin: 0;
  padding: 12px;
}

fieldset label {
  align-items: center;
  display: flex;
  gap: 8px;
}

input[type="checkbox"] {
  min-height: auto;
  width: auto;
}

.builder-actions {
  align-items: end;
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  grid-column: 1 / -1;
}

.environment-layout {
  display: grid;
  gap: 14px;
  grid-template-columns: minmax(220px, 0.8fr) minmax(280px, 2fr);
  margin-top: 16px;
}

.environment-list,
#environment-list,
#device-list {
  display: grid;
  gap: 10px;
}

.environment-row,
.device-row {
  border: 1px solid #d7e0e4;
  border-radius: 8px;
  padding: 12px;
}

.environment-row.active {
  border-color: #174f63;
  box-shadow: inset 3px 0 0 #174f63;
}

.device-row {
  display: grid;
  gap: 8px;
}

.device-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.ports {
  color: #5b6970;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 12px;
}

.device-note {
  color: #735413;
  font-size: 13px;
}

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

.filters {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 20px;
}

.filter.active {
  background: #174f63;
  border-color: #174f63;
  color: #ffffff;
}

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

.scenario-card {
  background: #ffffff;
  border: 1px solid #d7e0e4;
  border-radius: 8px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  min-height: 250px;
  padding: 16px;
}

.scenario-card h2 {
  line-height: 1.2;
}

.scenario-card p {
  color: #415059;
  line-height: 1.45;
}

.meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.pill {
  border: 1px solid #c9d6dc;
  border-radius: 999px;
  color: #31434b;
  font-size: 12px;
  padding: 3px 8px;
  text-transform: capitalize;
}

.critical {
  border-color: #e1a7a7;
  color: #8e1f1f;
}

.warning {
  border-color: #d9bc69;
  color: #735413;
}

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

.primary {
  background: #174f63;
  border-color: #174f63;
  color: #ffffff;
}

.run-panel {
  background: #ffffff;
  border: 1px solid #d7e0e4;
  border-radius: 8px;
  margin-top: 22px;
  padding: 16px;
}

pre {
  background: #101820;
  border-radius: 6px;
  color: #d9f7ff;
  min-height: 180px;
  overflow: auto;
  padding: 14px;
  white-space: pre-wrap;
}

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

  .card-actions {
    flex-direction: column;
  }

  .environment-layout {
    grid-template-columns: 1fr;
  }
}

.target-panel,
.controls-panel {
  background: #ffffff;
  border: 1px solid #d7e0e4;
  border-radius: 8px;
  margin-bottom: 22px;
  padding: 16px;
}

.target-grid {
  display: grid;
  gap: 12px;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  margin-top: 14px;
}

.target-actions {
  align-items: end;
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.control-grid {
  display: grid;
  gap: 14px;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  margin-top: 14px;
}

.control-card {
  border: 1px solid #d7e0e4;
  border-radius: 8px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 14px;
}

.control-card h3 {
  margin: 0;
}

.control-card p {
  color: #415059;
  line-height: 1.45;
}

.control-impact {
  font-size: 13px;
}

.control-card details {
  border-top: 1px solid #edf2f4;
  padding-top: 8px;
}

.control-card summary {
  cursor: pointer;
  font-weight: 650;
}

.control-params {
  display: grid;
  gap: 8px;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  margin-top: 10px;
}

.device-heading {
  align-items: center;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.device-select {
  align-items: center;
  display: flex;
  gap: 8px;
}

.device-select input {
  min-height: auto;
  width: auto;
}
