:root {
  --primary: #7643c9;
  --primary-dark: #5e32a7;
  --primary-soft: #f1ebfb;
  --ink: #16121f;
  --muted: #6f667d;
  --line: #ded7ea;
  --surface: #ffffff;
  --bg: #f6f3fb;
  --success: #14845e;
  --danger: #c93654;
  --warning: #b7791f;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background:
    linear-gradient(180deg, rgba(118, 67, 201, 0.12), rgba(246, 243, 251, 0) 360px),
    var(--bg);
  color: var(--ink);
  font-family: Inter, "Segoe UI", Arial, sans-serif;
  font-size: 14px;
  line-height: 1.5;
}

button,
input,
select {
  font: inherit;
}

button {
  cursor: pointer;
}

.app-shell {
  width: min(1500px, calc(100% - 32px));
  margin: 0 auto;
  padding: 22px 0 32px;
}

.hero {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 20px;
  min-height: 170px;
  padding: 30px;
  background:
    radial-gradient(circle at 80% 20%, rgba(118, 67, 201, 0.22), transparent 32%),
    linear-gradient(135deg, #241234, #52328c 58%, #7643c9);
  color: #fff;
  border-radius: 10px;
  box-shadow: 0 18px 42px rgba(63, 39, 104, 0.2);
}

.eyebrow {
  margin: 0 0 8px;
  color: #dacbf4;
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

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

h1 {
  font-size: clamp(34px, 6vw, 72px);
  line-height: 0.95;
}

h2 {
  font-size: 18px;
}

.hero-copy {
  max-width: 690px;
  margin: 14px 0 0;
  color: #eee7fb;
  font-size: 16px;
}

.docs-link,
.permanent-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 40px;
  padding: 8px 14px;
  color: #fff;
  text-decoration: none;
  background: rgba(255, 255, 255, 0.14);
  border: 1px solid rgba(255, 255, 255, 0.22);
  border-radius: 7px;
  font-weight: 800;
  white-space: nowrap;
}

.tool-panel,
.status-strip,
.nodes-panel,
.results-panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 10px;
  box-shadow: 0 14px 34px rgba(63, 39, 104, 0.08);
}

.tool-panel {
  margin-top: 16px;
  padding: 18px;
}

.type-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 16px;
}

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

.type-tab.active {
  background: var(--primary);
  color: #fff;
  border-color: var(--primary);
}

.form-grid {
  display: grid;
  grid-template-columns: minmax(280px, 1fr) 120px minmax(230px, 360px) 138px;
  gap: 12px;
  align-items: end;
}

.field {
  display: grid;
  gap: 7px;
}

.field span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.field input,
.field select {
  width: 100%;
  min-height: 44px;
  padding: 9px 11px;
  background: #fbf9fe;
  border: 1px solid var(--line);
  border-radius: 7px;
  color: var(--ink);
  outline: none;
}

.field input:focus,
.field select:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(118, 67, 201, 0.14);
}

#nodeSelect {
  height: 44px;
}

.run-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 44px;
  padding: 9px 16px;
  background: var(--primary);
  color: #fff;
  border: 1px solid var(--primary);
  border-radius: 7px;
  font-weight: 900;
}

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

.run-button:disabled {
  opacity: 0.65;
  cursor: wait;
}

.quick-examples {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 14px;
}

.quick-examples button,
.result-actions button,
#reloadNodes {
  min-height: 34px;
  padding: 6px 10px;
  background: var(--primary-soft);
  color: var(--primary-dark);
  border: 1px solid #d6c8ef;
  border-radius: 7px;
  font-weight: 800;
}

.status-strip {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr)) auto;
  gap: 10px;
  align-items: center;
  margin-top: 16px;
  padding: 14px 16px;
}

.metric-label {
  display: block;
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
  text-transform: uppercase;
}

.status-strip strong {
  display: block;
  margin-top: 3px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.status-strip .permanent-link {
  color: var(--primary);
  background: var(--primary-soft);
  border-color: #d6c8ef;
}

.hidden {
  display: none !important;
}

.result-layout {
  display: grid;
  grid-template-columns: 320px minmax(0, 1fr);
  gap: 16px;
  margin-top: 16px;
}

.nodes-panel,
.results-panel {
  min-height: 520px;
  padding: 16px;
}

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

.nodes-list {
  display: grid;
  gap: 8px;
  max-height: 650px;
  overflow: auto;
  padding-right: 4px;
}

.node-card {
  padding: 10px;
  background: #fbf9fe;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.node-card strong {
  display: block;
  font-size: 13px;
}

.node-card span {
  display: block;
  color: var(--muted);
  font-size: 12px;
}

.table-wrap {
  overflow: auto;
  max-height: 650px;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.info-panel {
  display: grid;
  gap: 14px;
}

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

.info-tile {
  padding: 13px;
  background: var(--primary-soft);
  border: 1px solid #d6c8ef;
  border-radius: 8px;
}

.info-tile span {
  display: block;
  color: var(--muted);
  font-size: 11px;
  font-weight: 900;
  text-transform: uppercase;
}

.info-tile strong {
  display: block;
  margin-top: 4px;
  overflow-wrap: anywhere;
}

.info-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(260px, 360px);
  gap: 14px;
}

.info-table {
  min-width: 0;
}

.info-table th {
  position: static;
  width: 155px;
  background: #f8f5fc;
  text-transform: none;
}

.info-side {
  display: grid;
  gap: 12px;
  align-content: start;
}

.map-box {
  min-height: 220px;
  padding: 16px;
  background: linear-gradient(135deg, #efe8fb, #ffffff);
  border: 1px solid var(--line);
  border-radius: 8px;
}

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

.source-pill {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  padding: 5px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 900;
}

.source-pill.ok {
  background: #def7ec;
  color: var(--success);
}

.source-pill.bad {
  background: #ffe2e8;
  color: var(--danger);
}

table {
  width: 100%;
  min-width: 860px;
  border-collapse: collapse;
  background: #fff;
}

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

th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: #f4f0fa;
  color: #423354;
  font-size: 12px;
  text-transform: uppercase;
}

td {
  color: #272033;
}

.empty-cell {
  padding: 42px 12px;
  color: var(--muted);
  text-align: center;
}

.badge {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 3px 9px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 900;
}

.badge.ok {
  background: #def7ec;
  color: var(--success);
}

.badge.bad {
  background: #ffe2e8;
  color: var(--danger);
}

.badge.pending {
  background: #fff2d4;
  color: var(--warning);
}

.mono {
  font-family: "SFMono-Regular", Consolas, monospace;
  font-size: 12px;
}

@media (max-width: 1050px) {
  .form-grid,
  .status-strip,
  .result-layout,
  .info-summary,
  .info-grid {
    grid-template-columns: 1fr;
  }

  .hero {
    align-items: flex-start;
    flex-direction: column;
  }
}

@media (max-width: 640px) {
  .app-shell {
    width: min(100% - 20px, 1500px);
    padding-top: 10px;
  }

  .hero,
  .tool-panel,
  .status-strip,
  .nodes-panel,
  .results-panel {
    border-radius: 8px;
    padding: 14px;
  }

  h1 {
    font-size: 38px;
  }
}
