:root {
  --bg: #eef2f4;
  --surface: #ffffff;
  --surface-2: #f7f9fb;
  --ink: #172027;
  --muted: #65727e;
  --line: #d9e1e7;
  --blue: #2563eb;
  --blue-dark: #1d4ed8;
  --green: #16834a;
  --green-bg: #e8f6ee;
  --amber: #b7791f;
  --amber-bg: #fff7e8;
  --red: #b42318;
  --red-bg: #fff0ee;
  --shadow: 0 18px 48px rgba(21, 32, 41, 0.1);
}

* {
  box-sizing: border-box;
}

html,
body {
  min-height: 100%;
}

body {
  margin: 0;
  font-family: Arial, Helvetica, sans-serif;
  color: var(--ink);
  background: var(--bg);
}

button,
input {
  font: inherit;
}

button {
  cursor: pointer;
}

.app-shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 280px minmax(0, 1fr);
}

.rail {
  background: #172027;
  color: #f8fbff;
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 24px;
}

.brand {
  display: flex;
  gap: 12px;
  align-items: center;
}

.brand-mark {
  width: 46px;
  height: 46px;
  display: grid;
  place-items: center;
  border-radius: 8px;
  background: linear-gradient(135deg, #2dd4bf, #60a5fa);
  color: #061217;
  font-weight: 900;
}

.brand h1 {
  margin: 0;
  font-size: 21px;
  letter-spacing: 0;
}

.brand p,
.rail-status small,
.panel-header p,
.eyebrow {
  margin: 0;
  color: var(--muted);
}

.brand p,
.rail-status small {
  color: #b8c3cc;
  font-size: 13px;
  margin-top: 3px;
}

.nav-list {
  display: grid;
  gap: 8px;
}

.nav-item {
  border: 0;
  width: 100%;
  min-height: 44px;
  border-radius: 8px;
  background: transparent;
  color: #d6dee6;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 12px;
  text-align: left;
}

.nav-item:hover,
.nav-item.active {
  background: rgba(255, 255, 255, 0.1);
  color: #ffffff;
}

.nav-item svg,
.top-actions svg,
.ghost-button svg,
.primary-button svg,
.secondary-button svg,
.icon-button svg,
.mode-option svg,
.route-grid svg {
  width: 18px;
  height: 18px;
  stroke-width: 2.2;
}

.rail-status {
  margin-top: auto;
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 8px;
  padding: 12px;
  display: flex;
  gap: 10px;
  align-items: center;
}

.status-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: #33d17a;
  box-shadow: 0 0 0 6px rgba(51, 209, 122, 0.16);
  flex: 0 0 auto;
}

.workspace {
  min-width: 0;
  padding: 24px;
}

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

.eyebrow {
  text-transform: uppercase;
  font-size: 12px;
  font-weight: 800;
  color: var(--blue);
}

.topbar h2 {
  margin: 4px 0 0;
  font-size: clamp(24px, 4vw, 38px);
  letter-spacing: 0;
}

.top-actions,
.export-actions {
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
}

.view {
  display: none;
}

.view.active {
  display: block;
}

.creation-grid {
  display: grid;
  grid-template-columns: minmax(320px, 1.1fr) minmax(320px, 0.9fr);
  gap: 16px;
}

.lower-grid {
  display: grid;
  grid-template-columns: minmax(320px, 1.1fr) minmax(320px, 0.9fr);
  gap: 16px;
  margin-top: 16px;
}

.execution-panel {
  margin-top: 16px;
}

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

.full-panel {
  min-height: 420px;
}

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

.panel-header h3 {
  margin: 0;
  font-size: 18px;
  letter-spacing: 0;
}

.panel-header p {
  margin-top: 4px;
  font-size: 13px;
}

.pill {
  min-height: 30px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0 10px;
  border-radius: 999px;
  color: var(--green);
  background: var(--green-bg);
  font-weight: 800;
  font-size: 13px;
  white-space: nowrap;
}

.pill.warn {
  color: var(--amber);
  background: var(--amber-bg);
}

.pill.error {
  color: var(--red);
  background: var(--red-bg);
}

.field-group {
  display: grid;
  gap: 7px;
  margin-bottom: 14px;
}

label {
  font-weight: 800;
  font-size: 13px;
}

input[type="text"] {
  width: 100%;
  height: 44px;
  border: 1px solid var(--line);
  background: var(--surface-2);
  border-radius: 8px;
  padding: 0 12px;
  color: var(--ink);
  outline: none;
}

input[type="text"]:focus {
  border-color: var(--blue);
  box-shadow: 0 0 0 4px rgba(37, 99, 235, 0.12);
}

.split-fields {
  display: grid;
  grid-template-columns: minmax(0, 0.7fr) minmax(0, 1.3fr);
  gap: 12px;
}

.mode-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-2);
  padding: 4px;
  margin: 4px 0 16px;
}

.mode-option {
  border: 0;
  height: 40px;
  border-radius: 6px;
  background: transparent;
  color: var(--muted);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font-weight: 800;
}

.mode-option.active {
  background: var(--surface);
  color: var(--blue);
  box-shadow: 0 6px 18px rgba(21, 32, 41, 0.08);
}

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

.switch-row {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 11px 12px;
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
  background: var(--surface-2);
}

.switch-row strong,
.switch-row small {
  display: block;
}

.switch-row small {
  margin-top: 2px;
  color: var(--muted);
  font-weight: 400;
}

input[type="checkbox"] {
  width: 42px;
  height: 24px;
  flex: 0 0 auto;
  accent-color: var(--blue);
}

.primary-button,
.secondary-button,
.ghost-button,
.icon-button {
  border-radius: 8px;
  min-height: 42px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 0 13px;
  font-weight: 800;
  white-space: nowrap;
}

.primary-button {
  border: 1px solid var(--blue);
  background: var(--blue);
  color: #ffffff;
}

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

.secondary-button,
.ghost-button {
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--ink);
}

.secondary-button:hover,
.ghost-button:hover {
  border-color: #b8c4cf;
  background: var(--surface-2);
}

.icon-button {
  width: 42px;
  padding: 0;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--ink);
}

.icon-button.compact {
  width: 34px;
  min-height: 34px;
}

.domain-card {
  min-height: 76px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f2f7ff;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 34px;
  gap: 8px;
  align-items: center;
  padding: 12px;
  margin-bottom: 12px;
}

.domain-card span {
  grid-column: 1;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}

.domain-card strong {
  grid-column: 1;
  font-size: clamp(17px, 2vw, 23px);
  min-width: 0;
  overflow-wrap: anywhere;
}

.domain-card .icon-button {
  grid-column: 2;
  grid-row: 1 / span 2;
}

.status-list {
  display: grid;
  gap: 8px;
  margin-bottom: 12px;
}

.status-item {
  min-height: 38px;
  display: grid;
  grid-template-columns: 22px minmax(0, 1fr);
  gap: 9px;
  align-items: center;
  padding: 8px 10px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: var(--surface-2);
}

.status-item svg {
  width: 18px;
  height: 18px;
}

.status-item.ok svg {
  color: var(--green);
}

.status-item.warn svg {
  color: var(--amber);
}

.status-item.error svg {
  color: var(--red);
}

.status-item strong {
  display: block;
  font-size: 13px;
}

.status-item span {
  display: block;
  color: var(--muted);
  font-size: 12px;
  margin-top: 2px;
}

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

.route-grid article {
  min-height: 92px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: var(--surface-2);
  padding: 12px;
  display: grid;
  align-content: start;
  gap: 6px;
}

.route-grid span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}

.route-grid strong {
  min-width: 0;
  overflow-wrap: anywhere;
}

pre {
  margin: 0;
  min-height: 300px;
  max-height: 440px;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #111820;
  color: #dbeafe;
  padding: 14px;
  font-size: 13px;
  line-height: 1.5;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

#execution-log {
  min-height: 160px;
  max-height: 280px;
}

.host-table {
  display: grid;
  gap: 8px;
}

.host-row {
  display: grid;
  grid-template-columns: minmax(180px, 1.1fr) minmax(160px, 0.8fr) 90px 90px;
  gap: 10px;
  align-items: center;
  border: 1px solid var(--line);
  background: var(--surface-2);
  border-radius: 8px;
  min-height: 54px;
  padding: 10px 12px;
}

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

.host-row span {
  color: var(--muted);
  overflow-wrap: anywhere;
}

.badge {
  display: inline-flex;
  justify-content: center;
  align-items: center;
  min-height: 28px;
  border-radius: 999px;
  padding: 0 10px;
  background: var(--green-bg);
  color: var(--green);
  font-weight: 800;
  font-size: 12px;
}

.badge.off {
  background: var(--amber-bg);
  color: var(--amber);
}

.export-actions {
  padding-top: 4px;
}

.toast {
  position: fixed;
  right: 20px;
  bottom: 20px;
  max-width: min(360px, calc(100vw - 40px));
  background: #172027;
  color: #ffffff;
  border-radius: 8px;
  padding: 12px 14px;
  box-shadow: var(--shadow);
  opacity: 0;
  transform: translateY(14px);
  pointer-events: none;
  transition: opacity 160ms ease, transform 160ms ease;
}

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

@media (max-width: 1120px) {
  .app-shell {
    grid-template-columns: 88px minmax(0, 1fr);
  }

  .brand div:last-child,
  .nav-item span,
  .rail-status div {
    display: none;
  }

  .brand {
    justify-content: center;
  }

  .nav-item {
    justify-content: center;
    padding: 0;
  }

  .creation-grid,
  .lower-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 720px) {
  .app-shell {
    display: block;
  }

  .rail {
    min-height: auto;
    padding: 12px;
    flex-direction: row;
    align-items: center;
    overflow: auto;
  }

  .brand div:last-child,
  .nav-item span {
    display: block;
  }

  .brand {
    min-width: 172px;
  }

  .nav-list {
    grid-auto-flow: column;
    grid-auto-columns: max-content;
  }

  .nav-item {
    width: auto;
    padding: 0 12px;
  }

  .rail-status {
    display: none;
  }

  .workspace {
    padding: 16px;
  }

  .topbar,
  .panel-header {
    align-items: flex-start;
    flex-direction: column;
  }

  .top-actions {
    width: 100%;
  }

  .primary-button,
  .secondary-button,
  .ghost-button {
    flex: 1 1 auto;
  }

  .split-fields,
  .switch-grid,
  .route-grid {
    grid-template-columns: 1fr;
  }

  .host-row {
    grid-template-columns: 1fr;
  }
}
