:root {
  --lab-ink: #17211f;
  --lab-muted: #5b6965;
  --lab-line: #d6dfdc;
  --lab-surface: #ffffff;
  --lab-canvas: #f2f6f4;
  --lab-green: #15705f;
  --lab-green-soft: #e2f2ed;
  --lab-blue: #2169a8;
  --lab-blue-soft: #e8f1fa;
  --lab-yellow: #8a5d00;
  --lab-yellow-soft: #fff3cf;
  --lab-red: #ad3d3d;
  --lab-red-soft: #fbe9e7;
  --lab-violet: #67529a;
  --lab-violet-soft: #eeeafa;
  --lab-shadow: 0 8px 24px rgba(23, 33, 31, 0.07);
}

* {
  box-sizing: border-box;
  letter-spacing: 0;
}

body.connectivity-lab-page {
  margin: 0;
  color: var(--lab-ink);
  background: var(--lab-canvas);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

.connectivity-lab-page button,
.connectivity-lab-page input {
  font: inherit;
}

.connectivity-lab-page .site-header {
  background: #ffffff;
  border-bottom: 1px solid var(--lab-line);
}

.connectivity-lab-page .nav {
  width: min(1480px, calc(100% - 40px));
  max-width: none;
  min-height: 64px;
}

.connectivity-shell {
  width: min(1480px, calc(100% - 40px));
  max-width: none;
  margin: 0 auto;
  padding: 24px 0 34px;
}

.eyebrow {
  margin: 0 0 5px;
  color: var(--lab-muted);
  font-size: 0.72rem;
  font-weight: 750;
  line-height: 1.2;
  text-transform: uppercase;
}

.lab-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  margin-bottom: 14px;
}

.lab-toolbar h1 {
  margin: 0;
  max-width: 760px;
  font-size: 2rem;
  line-height: 1.12;
}

.run-label {
  display: flex;
  align-items: center;
  gap: 7px;
  margin: 8px 0 0;
  color: var(--lab-muted);
  font-size: 0.86rem;
}

.run-label strong {
  color: var(--lab-ink);
}

.live-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #1a9b77;
  box-shadow: 0 0 0 3px var(--lab-green-soft);
}

.toolbar-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  flex-wrap: wrap;
}

.tool-button,
.run-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 40px;
  padding: 8px 12px;
  border: 1px solid #c5cfcc;
  border-radius: 6px;
  background: #ffffff;
  color: var(--lab-ink);
  font-weight: 720;
  cursor: pointer;
}

.tool-button:hover {
  background: #f7f9f8;
  border-color: #96a7a2;
}

.tool-button svg,
.run-button svg {
  width: 17px;
  height: 17px;
}

.run-button.button.primary {
  min-width: 150px;
  border-color: var(--lab-green);
  background: var(--lab-green);
  color: #ffffff;
}

.run-button.button.primary:hover {
  background: #0f5d4e;
}

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

.synthetic-notice {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  margin-bottom: 14px;
  padding: 10px 12px;
  border: 1px solid #efd994;
  border-left: 4px solid #d29a1e;
  border-radius: 4px;
  background: #fff9e9;
  color: #634d19;
  font-size: 0.85rem;
  line-height: 1.45;
}

.synthetic-notice svg {
  width: 18px;
  min-width: 18px;
  margin-top: 1px;
}

.metric-strip {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  margin-bottom: 14px;
  border: 1px solid var(--lab-line);
  border-radius: 6px;
  background: var(--lab-surface);
  box-shadow: var(--lab-shadow);
}

.metric-cell {
  min-height: 96px;
  padding: 15px 18px;
  border-right: 1px solid var(--lab-line);
}

.metric-cell:last-child {
  border-right: 0;
}

.metric-cell span,
.metric-cell small {
  display: block;
  color: var(--lab-muted);
}

.metric-cell span {
  font-size: 0.75rem;
  font-weight: 750;
  text-transform: uppercase;
}

.metric-cell strong {
  display: block;
  margin: 3px 0 1px;
  font-size: 1.7rem;
  line-height: 1;
}

.metric-cell small {
  font-size: 0.76rem;
}

.metric-cell.metric-safety {
  border-top: 3px solid var(--lab-red);
}

.scenario-bar {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 20px;
  padding: 14px 16px;
  border: 1px solid var(--lab-line);
  border-bottom: 0;
  border-radius: 6px 6px 0 0;
  background: #ffffff;
}

.scenario-bar h2,
.panel-heading h2,
.mapping-title h3,
.validation-heading h3 {
  margin: 0;
  font-size: 1rem;
  line-height: 1.25;
}

.scenario-segments {
  display: flex;
  align-items: center;
  gap: 3px;
  max-width: 100%;
  padding: 3px;
  border: 1px solid var(--lab-line);
  border-radius: 6px;
  background: #f1f4f3;
  overflow-x: auto;
}

.scenario-segments button {
  min-height: 34px;
  padding: 6px 10px;
  border: 0;
  border-radius: 4px;
  background: transparent;
  color: var(--lab-muted);
  font-size: 0.78rem;
  font-weight: 700;
  white-space: nowrap;
  cursor: pointer;
}

.scenario-segments button:hover {
  color: var(--lab-ink);
  background: #ffffff;
}

.scenario-segments button[aria-selected="true"] {
  color: #ffffff;
  background: var(--lab-ink);
  box-shadow: 0 1px 3px rgba(23, 33, 31, 0.18);
}

.workspace-grid {
  display: grid;
  grid-template-columns: 230px minmax(500px, 1fr) 285px;
  align-items: stretch;
  min-height: 620px;
  margin-bottom: 14px;
  border: 1px solid var(--lab-line);
  border-radius: 0 0 6px 6px;
  background: var(--lab-surface);
  box-shadow: var(--lab-shadow);
  overflow: hidden;
}

.endpoint-panel,
.pipeline-panel,
.decision-panel {
  min-width: 0;
  padding: 16px;
}

.endpoint-panel {
  border-right: 1px solid var(--lab-line);
  background: #f9fbfa;
}

.decision-panel {
  border-left: 1px solid var(--lab-line);
  background: #f9fbfa;
}

.panel-heading,
.mapping-title,
.validation-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.inventory-count,
.evidence-count {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 28px;
  min-height: 24px;
  padding: 3px 7px;
  border-radius: 4px;
  background: #e6ecea;
  color: var(--lab-muted);
  font-size: 0.76rem;
  font-weight: 800;
}

.endpoint-list {
  display: grid;
  gap: 8px;
  margin-top: 15px;
}

.endpoint-row {
  display: grid;
  grid-template-columns: 36px minmax(0, 1fr) auto;
  align-items: center;
  gap: 9px;
  min-height: 62px;
  padding: 9px;
  border: 1px solid var(--lab-line);
  border-radius: 6px;
  background: #ffffff;
  transition: border-color 150ms ease, box-shadow 150ms ease;
}

.endpoint-row.active {
  border-color: var(--lab-blue);
  box-shadow: inset 3px 0 0 var(--lab-blue);
}

.endpoint-row strong,
.endpoint-row small {
  display: block;
  min-width: 0;
}

.endpoint-row strong {
  font-size: 0.84rem;
}

.endpoint-row small {
  margin-top: 2px;
  color: var(--lab-muted);
  font-size: 0.7rem;
  line-height: 1.3;
}

.protocol-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  border-radius: 6px;
}

.protocol-icon svg {
  width: 17px;
  height: 17px;
}

.protocol-sila {
  color: var(--lab-violet);
  background: var(--lab-violet-soft);
}

.protocol-opc {
  color: var(--lab-blue);
  background: var(--lab-blue-soft);
}

.protocol-mqtt {
  color: var(--lab-green);
  background: var(--lab-green-soft);
}

.protocol-modbus {
  color: var(--lab-yellow);
  background: var(--lab-yellow-soft);
}

.endpoint-state {
  color: var(--lab-green);
  font-size: 0.65rem;
  font-weight: 800;
  text-transform: uppercase;
}

.sandbox-boundary,
.decision-facts {
  margin: 16px 0 0;
  padding-top: 12px;
  border-top: 1px solid var(--lab-line);
}

.sandbox-boundary div,
.decision-facts div {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  padding: 6px 0;
}

.sandbox-boundary dt,
.decision-facts dt {
  color: var(--lab-muted);
  font-size: 0.72rem;
}

.sandbox-boundary dd,
.decision-facts dd {
  margin: 0;
  max-width: 60%;
  color: var(--lab-ink);
  font-size: 0.72rem;
  font-weight: 700;
  text-align: right;
  overflow-wrap: anywhere;
}

.run-state,
.access-badge {
  display: inline-flex;
  align-items: center;
  min-height: 25px;
  padding: 4px 8px;
  border-radius: 4px;
  font-size: 0.7rem;
  font-weight: 800;
}

.run-state.ready {
  color: var(--lab-muted);
  background: #edf1f0;
}

.run-state.running {
  color: var(--lab-blue);
  background: var(--lab-blue-soft);
}

.run-state.complete {
  color: var(--lab-green);
  background: var(--lab-green-soft);
}

.pipeline {
  display: grid;
  grid-template-columns: minmax(120px, 1fr) 18px minmax(120px, 1fr) 18px minmax(120px, 1fr) 18px minmax(120px, 1fr);
  align-items: center;
  gap: 5px;
  margin: 16px 0;
}

.pipeline-stage {
  position: relative;
  display: grid;
  grid-template-columns: 24px minmax(0, 1fr) 18px;
  align-items: center;
  gap: 7px;
  min-height: 66px;
  padding: 9px;
  border: 1px solid var(--lab-line);
  border-radius: 6px;
  background: #ffffff;
}

.pipeline-stage > span {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 23px;
  height: 23px;
  border-radius: 50%;
  background: #e8edeb;
  color: var(--lab-muted);
  font-size: 0.7rem;
  font-weight: 800;
}

.pipeline-stage strong,
.pipeline-stage small {
  display: block;
}

.pipeline-stage strong {
  font-size: 0.75rem;
}

.pipeline-stage small {
  margin-top: 2px;
  color: var(--lab-muted);
  font-size: 0.64rem;
  line-height: 1.25;
}

.pipeline-stage > svg {
  width: 16px;
  height: 16px;
  color: #7d8a86;
}

.pipeline-stage.running {
  border-color: var(--lab-blue);
  box-shadow: 0 0 0 2px var(--lab-blue-soft);
}

.pipeline-stage.passed {
  border-color: #70af9e;
  background: #f5fbf8;
}

.pipeline-stage.passed > span {
  color: #ffffff;
  background: var(--lab-green);
}

.pipeline-stage.review {
  border-color: #d3aa54;
  background: #fffbef;
}

.pipeline-stage.blocked {
  border-color: #d27b78;
  background: #fff8f7;
}

.stage-arrow {
  width: 16px;
  color: #a0aaa7;
}

.mapping-block,
.validation-block {
  margin-top: 14px;
  padding: 14px;
  border: 1px solid var(--lab-line);
  border-radius: 6px;
  background: #ffffff;
}

.access-badge.read {
  color: var(--lab-blue);
  background: var(--lab-blue-soft);
}

.access-badge.write {
  color: var(--lab-yellow);
  background: var(--lab-yellow-soft);
}

.mapping-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1px;
  margin-top: 12px;
  border: 1px solid var(--lab-line);
  border-radius: 4px;
  background: var(--lab-line);
  overflow: hidden;
}

.mapping-grid > div {
  min-height: 64px;
  padding: 10px;
  background: #f9fbfa;
}

.mapping-grid span,
.mapping-grid strong {
  display: block;
}

.mapping-grid span {
  margin-bottom: 4px;
  color: var(--lab-muted);
  font-size: 0.68rem;
  font-weight: 700;
  text-transform: uppercase;
}

.mapping-grid strong {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.75rem;
  line-height: 1.35;
  overflow-wrap: anywhere;
}

.validation-heading > span {
  color: var(--lab-muted);
  font-size: 0.72rem;
  font-weight: 800;
}

.gate-list {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 7px;
  margin-top: 12px;
}

.gate-row {
  display: grid;
  grid-template-columns: 22px minmax(0, 1fr) auto;
  align-items: center;
  gap: 7px;
  min-height: 50px;
  padding: 8px;
  border: 1px solid var(--lab-line);
  border-radius: 5px;
  background: #fbfcfc;
}

.gate-row .gate-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 21px;
  height: 21px;
  border-radius: 50%;
  color: #ffffff;
  background: #9ca7a4;
}

.gate-row .gate-icon svg {
  width: 13px;
  height: 13px;
}

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

.gate-row strong {
  font-size: 0.72rem;
}

.gate-row small {
  margin-top: 2px;
  color: var(--lab-muted);
  font-size: 0.62rem;
  line-height: 1.25;
}

.gate-row b {
  color: var(--lab-muted);
  font-size: 0.62rem;
  text-transform: uppercase;
}

.gate-row.pass .gate-icon {
  background: var(--lab-green);
}

.gate-row.pass b {
  color: var(--lab-green);
}

.gate-row.fail .gate-icon {
  background: var(--lab-red);
}

.gate-row.fail b {
  color: var(--lab-red);
}

.gate-row.review .gate-icon {
  background: #b17b15;
}

.gate-row.review b {
  color: var(--lab-yellow);
}

.decision-hero {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 230px;
  margin-top: 15px;
  padding: 20px 14px;
  border: 1px solid var(--lab-line);
  border-top: 4px solid #9ca7a4;
  border-radius: 6px;
  background: #ffffff;
  text-align: center;
}

.decision-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 52px;
  height: 52px;
  border-radius: 50%;
  color: #66736f;
  background: #e9eeec;
}

.decision-icon svg {
  width: 26px;
  height: 26px;
}

.decision-hero p {
  margin: 14px 0 3px;
  color: var(--lab-muted);
  font-size: 0.68rem;
  font-weight: 800;
  text-transform: uppercase;
}

.decision-hero strong {
  font-size: 1.1rem;
  line-height: 1.25;
}

.decision-hero small {
  display: block;
  max-width: 220px;
  margin-top: 7px;
  color: var(--lab-muted);
  font-size: 0.72rem;
  line-height: 1.45;
}

.decision-hero.accepted {
  border-top-color: var(--lab-green);
}

.decision-hero.accepted .decision-icon {
  color: var(--lab-green);
  background: var(--lab-green-soft);
}

.decision-hero.review {
  border-top-color: #c59024;
}

.decision-hero.review .decision-icon {
  color: var(--lab-yellow);
  background: var(--lab-yellow-soft);
}

.decision-hero.blocked {
  border-top-color: var(--lab-red);
}

.decision-hero.blocked .decision-icon {
  color: var(--lab-red);
  background: var(--lab-red-soft);
}

.approval-control {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  min-height: 58px;
  margin-top: 10px;
  padding: 10px;
  border: 1px solid #d9bd7a;
  border-radius: 6px;
  background: #fffaf0;
  cursor: pointer;
}

.approval-control[hidden] {
  display: none;
}

.approval-control > span:first-child {
  display: flex;
  align-items: center;
  gap: 8px;
}

.approval-control svg {
  width: 18px;
  height: 18px;
  color: var(--lab-yellow);
}

.approval-control strong,
.approval-control small {
  display: block;
}

.approval-control strong {
  font-size: 0.75rem;
}

.approval-control small {
  color: var(--lab-muted);
  font-size: 0.65rem;
}

.approval-control input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.approval-control .toggle {
  position: relative;
  width: 38px;
  min-width: 38px;
  height: 22px;
  border-radius: 12px;
  background: #aeb8b5;
  transition: background 150ms ease;
}

.approval-control .toggle::after {
  position: absolute;
  top: 3px;
  left: 3px;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: #ffffff;
  content: "";
  transition: transform 150ms ease;
}

.approval-control input:checked + .toggle {
  background: var(--lab-green);
}

.approval-control input:checked + .toggle::after {
  transform: translateX(16px);
}

.approval-control:focus-within {
  outline: 2px solid var(--lab-blue);
  outline-offset: 2px;
}

.boundary-note {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  margin-top: 14px;
  padding: 10px;
  border-left: 3px solid var(--lab-violet);
  background: var(--lab-violet-soft);
  color: #43386b;
}

.boundary-note svg {
  width: 17px;
  min-width: 17px;
  margin-top: 1px;
}

.boundary-note p {
  margin: 0;
  font-size: 0.68rem;
  line-height: 1.45;
}

.evidence-panel {
  padding: 16px;
  border: 1px solid var(--lab-line);
  border-radius: 6px;
  background: var(--lab-surface);
  box-shadow: var(--lab-shadow);
}

.evidence-table-wrap {
  margin-top: 13px;
  border: 1px solid var(--lab-line);
  border-radius: 5px;
  overflow-x: auto;
}

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

.evidence-table th,
.evidence-table td {
  padding: 9px 10px;
  border-bottom: 1px solid var(--lab-line);
  font-size: 0.72rem;
  text-align: left;
  vertical-align: top;
}

.evidence-table th {
  color: var(--lab-muted);
  background: #f6f8f7;
  font-size: 0.66rem;
  text-transform: uppercase;
}

.evidence-table tr:last-child td {
  border-bottom: 0;
}

.evidence-table code {
  font-size: 0.69rem;
  overflow-wrap: anywhere;
}

.result-pill {
  display: inline-flex;
  align-items: center;
  min-height: 21px;
  padding: 3px 6px;
  border-radius: 4px;
  font-size: 0.62rem;
  font-weight: 800;
  text-transform: uppercase;
}

.result-pill.accepted {
  color: var(--lab-green);
  background: var(--lab-green-soft);
}

.result-pill.review {
  color: var(--lab-yellow);
  background: var(--lab-yellow-soft);
}

.result-pill.blocked {
  color: var(--lab-red);
  background: var(--lab-red-soft);
}

.result-pill.ready {
  color: var(--lab-muted);
  background: #e9eeec;
}

.lab-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  width: min(1480px, calc(100% - 40px));
  max-width: none;
  margin: 0 auto;
  padding: 18px 0 28px;
  color: var(--lab-muted);
  font-size: 0.72rem;
}

@media (max-width: 1180px) {
  .workspace-grid {
    grid-template-columns: 210px minmax(460px, 1fr);
  }

  .decision-panel {
    grid-column: 1 / -1;
    display: grid;
    grid-template-columns: minmax(230px, 0.8fr) minmax(250px, 1fr) minmax(250px, 1fr);
    gap: 14px;
    border-top: 1px solid var(--lab-line);
    border-left: 0;
  }

  .decision-panel > .panel-heading {
    grid-column: 1 / -1;
  }

  .decision-hero {
    min-height: 190px;
    margin-top: 0;
  }

  .approval-control,
  .decision-facts {
    align-self: start;
    margin-top: 0;
  }

  .boundary-note {
    align-self: start;
    margin-top: 0;
  }
}

@media (max-width: 900px) {
  .connectivity-shell,
  .connectivity-lab-page .nav,
  .lab-footer {
    width: min(100% - 24px, 760px);
  }

  .lab-toolbar,
  .scenario-bar {
    align-items: stretch;
    flex-direction: column;
  }

  .toolbar-actions {
    justify-content: flex-start;
  }

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

  .metric-cell:nth-child(2) {
    border-right: 0;
  }

  .metric-cell:nth-child(-n + 2) {
    border-bottom: 1px solid var(--lab-line);
  }

  .workspace-grid {
    grid-template-columns: 1fr;
  }

  .endpoint-panel {
    border-right: 0;
    border-bottom: 1px solid var(--lab-line);
  }

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

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

  .stage-arrow {
    display: none;
  }

  .decision-panel {
    grid-template-columns: 1fr 1fr;
  }

  .boundary-note {
    grid-column: 1 / -1;
  }
}

@media (max-width: 640px) {
  .connectivity-shell {
    padding-top: 18px;
  }

  .connectivity-lab-page .nav-links a:not(.nav-cta) {
    display: none;
  }

  .lab-toolbar h1 {
    font-size: 1.55rem;
  }

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

  .run-button.button.primary {
    grid-column: 1 / -1;
    width: 100%;
  }

  .metric-cell {
    min-height: 88px;
    padding: 13px;
  }

  .scenario-segments {
    width: 100%;
  }

  .endpoint-list,
  .mapping-grid,
  .gate-list,
  .decision-panel {
    grid-template-columns: 1fr;
  }

  .pipeline {
    grid-template-columns: 1fr;
  }

  .pipeline-stage {
    min-height: 56px;
  }

  .decision-panel > .panel-heading,
  .boundary-note {
    grid-column: auto;
  }

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

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    transition-duration: 0.01ms !important;
  }
}
