.panel-port-fields {
  min-width: 0;
  display: grid;
  gap: 8px;
}

.panel-port-fields select {
  width: 100%;
  height: 34px;
  margin: 0 !important;
  padding: 0 28px 0 9px;
  border: 1px solid #d8e0e8;
  border-radius: 6px;
  color: #334155;
  background: #fff;
  font-size: 11px;
}

.panel-port-fields select:focus-visible {
  outline: 2px solid #0f8f8a;
  outline-offset: 1px;
}

.panel-port-add-assignment {
  justify-self: start;
  min-height: 30px;
  padding: 0 9px;
  border: 1px dashed #8fded9;
  border-radius: 6px;
  color: #087f7b;
  background: #f5fcfb;
  cursor: pointer;
  font: 750 10px Manrope, Arial, sans-serif;
}

.panel-port-add-assignment:hover:not(:disabled) { background: #eaf8f7; }
.panel-port-add-assignment:disabled { opacity: .5; cursor: not-allowed; }

.panel-port-assignment-fields {
  padding: 8px;
  border: 1px solid #ccebe8;
  border-radius: 7px;
  background: #f4fbfa;
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(88px, .45fr) 26px;
  gap: 7px;
  align-items: end;
}

.panel-port-assignment-fields .panel-port-remove-assignment {
  width: 26px;
  height: 34px;
  padding: 0;
  border: 0;
  border-radius: 6px;
  color: #9b5555;
  background: transparent;
  cursor: pointer;
  font-size: 17px;
}

.panel-port-assignment-fields .panel-port-remove-assignment:hover {
  color: #bd2d2d;
  background: #ffeded;
}

.panel-port-stage {
  display: block;
  cursor: grab;
  touch-action: none;
}

.panel-port-stage.is-panning {
  cursor: grabbing;
}

.panel-port-stage:focus-visible {
  outline: 3px solid #55d5cf;
  outline-offset: 2px;
}

.panel-port-stage.is-empty {
  display: grid;
  cursor: default;
}

.panel-calibration-fields {
  min-width: 0;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 9px 12px;
}

.panel-calibration-fields > label {
  min-width: 0;
  margin: 0 !important;
  color: #65758a;
  font-size: 11px;
  font-weight: 750;
}

.panel-calibration-fields > label > div {
  position: relative;
  margin-top: 7px;
}

.panel-calibration-fields input {
  width: 100%;
  height: 42px;
  margin: 0 !important;
  padding: 0 34px 0 11px;
  border: 1px solid #d8e0e8;
  border-radius: 8px;
  color: #334155;
  background: #fff;
  font-weight: 750;
  font-variant-numeric: tabular-nums;
}

.panel-calibration-fields input[aria-invalid="true"] {
  border-color: #ef9a9a;
}

.panel-calibration-fields label > div > span {
  position: absolute;
  right: 10px;
  top: 50%;
  color: #8a97a8;
  font-size: 10px;
  transform: translateY(-50%);
  pointer-events: none;
}

.panel-calibration-fields > small,
.panel-calibration-fields > .field-error {
  grid-column: 1 / -1;
  margin-top: 0;
  color: #718096;
  font-size: 10px;
  font-weight: 500;
  line-height: 1.45;
}

.panel-calibration-fields > .field-error { color: #c43b3b; }

.panel-image-layer {
  position: absolute;
  left: 50%;
  top: 50%;
  transform-origin: center;
  will-change: transform;
}

.panel-image-layer > img {
  width: 100%;
  height: 100%;
  max-width: none;
  max-height: none;
  object-fit: contain;
}

.panel-port-overlay {
  position: absolute;
}

.panel-calibration-line {
  position: absolute;
  z-index: 1;
  pointer-events: none;
}

.panel-calibration-line.is-width {
  height: 1px;
  background: #0f8f8a;
  box-shadow: 0 0 0 .5px #fff;
}

.panel-calibration-line.is-height {
  width: 1px;
  background: #2563eb;
  box-shadow: 0 0 0 .5px #fff;
}

.panel-calibration-handle {
  position: absolute;
  z-index: 3;
  width: 32px;
  height: 32px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: transparent;
  transform: translate(-50%, -50%);
  cursor: crosshair;
  touch-action: none;
}

.panel-calibration-handle::before,
.panel-calibration-handle::after {
  position: absolute;
  left: 50%;
  top: 50%;
  background: #fff;
  box-shadow: 0 0 0 1px currentColor;
  content: '';
  transform: translate(-50%, -50%);
}

.panel-calibration-handle::before { width: 9px; height: 1px; }
.panel-calibration-handle::after { width: 1px; height: 9px; }
.panel-calibration-handle.is-width { color: #0f8f8a; }
.panel-calibration-handle.is-height { color: #2563eb; }
.panel-calibration-handle:hover::before { width: 11px; }
.panel-calibration-handle:hover::after { height: 11px; }
.panel-calibration-handle:focus-visible {
  outline: 2px solid currentColor;
  outline-offset: -8px;
}

.panel-port-marker {
  z-index: 4;
  width: 32px;
  height: 32px;
}

.panel-port-marker span {
  width: 7px;
  height: 7px;
  border-width: 1px;
  font-size: 0;
}

.panel-port-marker:hover span {
  transform: scale(1.35);
}

.panel-port-marker.is-selected span {
  transform: scale(1.25);
  box-shadow: 0 0 0 3px #55d5cf99, 0 2px 7px #102a4366;
}

.panel-port-marker:focus-visible {
  outline: none;
}

.panel-port-marker:focus-visible span {
  box-shadow: 0 0 0 4px #55d5cf, 0 2px 7px #102a4366;
}

.panel-image-view-controls {
  position: absolute;
  z-index: 3;
  top: 12px;
  right: 12px;
  min-height: 36px;
  border: 1px solid #dce5ed;
  border-radius: 8px;
  background: #fff;
  display: inline-flex;
  align-items: stretch;
  overflow: hidden;
  box-shadow: 0 5px 16px #102a4324;
}

.panel-image-view-controls button,
.panel-image-view-controls output {
  min-width: 36px;
  min-height: 36px;
  padding: 0 9px;
  border: 0;
  border-right: 1px solid #e6ebf0;
  color: #526277;
  background: #fff;
  display: grid;
  place-items: center;
  font: 750 12px Manrope, Arial, sans-serif;
}

.panel-image-view-controls button {
  cursor: pointer;
}

.panel-image-view-controls button:hover:not(:disabled) {
  color: #087f7b;
  background: #effaf9;
}

.panel-image-view-controls button:focus-visible {
  position: relative;
  z-index: 1;
  outline: 2px solid #0f8f8a;
  outline-offset: -3px;
}

.panel-image-view-controls button:disabled {
  color: #a9b3bf;
  cursor: not-allowed;
}

.panel-image-view-controls output {
  min-width: 54px;
  color: #334155;
  font-variant-numeric: tabular-nums;
}

.panel-image-view-controls .panel-image-fit {
  min-width: 66px;
}

.panel-image-view-controls .panel-model-clear {
  min-width: 112px;
  border-right: 0;
  color: #9b4242;
}

.panel-image-view-controls .panel-model-clear:hover:not(:disabled) {
  color: #b42323;
  background: #fff3f3;
}

.panel-port-list-head {
  gap: 12px;
}

.panel-port-list-title {
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 8px;
}

.panel-port-list-head .panel-port-list-title > span {
  min-width: 25px;
  padding: 4px 7px;
  border-radius: 999px;
  color: #627185;
  background: #edf2f6;
  text-align: center;
  font-size: 10px;
  font-weight: 800;
}

.panel-port-list-head > button {
  min-width: 128px;
  min-height: 32px;
  padding: 0 10px;
  border: 1px solid #8fded9;
  border-radius: 7px;
  color: #087f7b;
  background: #f5fcfb;
  cursor: pointer;
  font: 750 10px Manrope, Arial, sans-serif;
}

.panel-port-list-head > button:hover:not(:disabled) {
  color: #075e5b;
  background: #eaf8f7;
}

.panel-port-list-head > button:focus-visible {
  outline: 2px solid #0f8f8a;
  outline-offset: 2px;
}

.panel-port-list-head > button:disabled {
  opacity: .45;
  cursor: not-allowed;
}

@media (max-width: 800px) {
  .panel-image-view-controls {
    top: 8px;
    right: 8px;
  }

  .panel-image-view-controls .panel-model-clear {
    min-width: 98px;
  }

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

  .panel-calibration-fields > label:last-of-type {
    grid-column: 1 / -1;
  }
}
