.rch-scope-editor{
  position:absolute;
  top:78px;
  right:14px;
  z-index:790;
  width:min(430px,calc(100vw - 28px));
  max-height:calc(100vh - 156px);
  overflow:auto;
  padding:14px;
  border:1px solid #d0d5dd;
  border-radius:14px;
  background:rgba(255,255,255,.98);
  box-shadow:0 18px 48px rgba(16,24,40,.18);
}

.rch-scope-editor[hidden]{display:none!important}

.rch-scope-editor__header{
  display:flex;
  align-items:flex-start;
  justify-content:space-between;
  gap:12px;
  margin-bottom:12px;
}

.rch-scope-editor__header h2{
  margin:2px 0 3px;
  font-size:18px;
}

.rch-scope-editor__header p{
  margin:0;
  color:#667085;
  font-size:11px;
  line-height:1.4;
}

.rch-scope-editor__state,
.rch-scope-editor__reference,
.rch-scope-editor__review,
.rch-scope-editor__notice,
.rch-scope-editor__preview{
  margin-top:10px;
  padding:10px 11px;
  border:1px solid #e4e7ec;
  border-radius:11px;
  background:#fff;
}

.rch-scope-editor__state{
  display:grid;
  gap:3px;
  background:#f8fafc;
}

.rch-scope-editor__state strong{
  font-size:11px;
  color:#101828;
}

.rch-scope-editor__state span{
  font-size:11px;
  color:#344054;
}

.rch-scope-editor__state small{
  color:#667085;
  font-size:9px;
}

.rch-scope-editor__reference{
  display:grid;
  gap:8px;
}

.rch-scope-editor__reference>div,
.rch-scope-editor__review-head{
  display:flex;
  align-items:flex-start;
  justify-content:space-between;
  gap:8px;
}

.rch-scope-editor__reference a{
  color:#175cd3;
  font-size:9px;
  text-decoration:none;
}

.rch-scope-editor__reference p,
.rch-scope-editor__preview-note,
.rch-scope-editor__footer-note{
  margin:0;
  color:#667085;
  font-size:9px;
  line-height:1.45;
}

.rch-scope-editor__toggle{
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:10px;
  padding:8px 9px;
  border:1px solid #e4e7ec;
  border-radius:9px;
  background:#f8fafc;
}

.rch-scope-editor__toggle>span{
  display:grid;
  gap:2px;
}

.rch-scope-editor__toggle strong{
  color:#344054;
  font-size:10px;
}

.rch-scope-editor__toggle small{
  color:#667085;
  font-size:9px;
}

.rch-scope-editor__toggle input{
  flex:0 0 auto;
  width:18px;
  height:18px;
  margin:0;
}

.rch-scope-editor__review{
  display:grid;
  gap:8px;
}

.rch-scope-editor__review-head strong{
  font-size:11px;
}

.rch-scope-editor__review-head span{
  color:#667085;
  font-size:9px;
  text-align:right;
}

.rch-scope-editor__checks{
  display:grid;
  grid-template-columns:1fr 1fr;
  gap:6px;
}

.rch-scope-editor__check{
  display:flex;
  align-items:flex-start;
  gap:6px;
  min-width:0;
  padding:7px 8px;
  border:1px solid #e4e7ec;
  border-radius:8px;
  background:#f8fafc;
  color:#344054;
  font-size:9px;
  line-height:1.3;
}

.rch-scope-editor__check input{
  flex:0 0 auto;
  margin:1px 0 0;
}

.rch-scope-editor__actions{
  display:grid;
  grid-template-columns:1fr 1fr;
  gap:7px;
  margin-top:10px;
}

.rch-scope-editor__actions .btn{
  min-width:0;
  white-space:normal;
  line-height:1.2;
}

.rch-scope-editor__notice{
  color:#344054;
  font-size:10px;
  line-height:1.45;
  background:#f9f5ff;
  border-color:#e9d7fe;
}

.rch-scope-editor__preview{
  display:grid;
  gap:9px;
}

.rch-scope-editor__preview-title{
  display:flex;
  align-items:flex-start;
  justify-content:space-between;
  gap:8px;
}

.rch-scope-editor__preview-title strong{
  font-size:12px;
}

.rch-scope-editor__preview-title span{
  color:#667085;
  font-size:9px;
  text-align:right;
}

.rch-scope-editor__metrics{
  display:grid;
  grid-template-columns:1fr 1fr;
  gap:7px;
}

.rch-scope-editor__metric{
  min-width:0;
  padding:8px 9px;
  border:1px solid #e4e7ec;
  border-radius:9px;
  background:#fff;
}

.rch-scope-editor__metric strong{
  display:block;
  font-size:15px;
  line-height:1.1;
}

.rch-scope-editor__metric span{
  display:block;
  margin-top:3px;
  color:#667085;
  font-size:9px;
  line-height:1.2;
}

.rch-scope-editor__metric.primary{
  border-color:#b2ddff;
  background:#f0f9ff;
}

.rch-scope-editor__metric.warning{
  border-color:#fedf89;
  background:#fffaeb;
}

.rch-scope-editor__footer-note{
  margin-top:10px;
  font-weight:600;
}

@media (max-width:900px){
  .rch-scope-editor{
    top:auto;
    right:10px;
    bottom:76px;
    left:10px;
    width:auto;
    max-height:min(70vh,650px);
  }
}

@media (max-width:430px){
  .rch-scope-editor{
    padding:12px;
  }

  .rch-scope-editor__checks,
  .rch-scope-editor__actions,
  .rch-scope-editor__metrics{
    grid-template-columns:1fr;
  }
}


.rch-scope-editor__mixed-warning{
  display:flex;
  align-items:flex-start;
  gap:8px;
  margin-top:8px;
  padding:9px 10px;
  border:1px solid #fedf89;
  border-radius:10px;
  background:#fffaeb;
}

.rch-scope-editor__mixed-warning i{
  flex:0 0 auto;
  width:9px;
  height:9px;
  margin-top:3px;
  border:2px dashed #b54708;
  border-radius:3px;
  background:rgba(247,144,9,.12);
}

.rch-scope-editor__mixed-warning span{
  display:grid;
  gap:2px;
  min-width:0;
}

.rch-scope-editor__mixed-warning strong{
  color:#93370d;
  font-size:10px;
  line-height:1.25;
}

.rch-scope-editor__mixed-warning small{
  color:#854a0e;
  font-size:9px;
  line-height:1.35;
}


.rch-scope-editor__reference-actions{
  display:grid;
  grid-template-columns:minmax(0,1fr) minmax(0,1fr);
  gap:7px;
  margin-top:8px;
}

.rch-scope-editor__reference-action-link{
  display:flex;
  align-items:center;
  justify-content:center;
  min-width:0;
  padding:7px 9px;
  border:1px solid #d0d5dd;
  border-radius:8px;
  background:#fff;
  color:#344054;
  font-size:9px;
  font-weight:700;
  line-height:1.2;
  text-align:center;
  text-decoration:none;
}

.rch-scope-editor__reference-action-link:hover{
  border-color:#98a2b3;
  background:#f9fafb;
}

.rch-scope-editor__north-rule{
  margin:7px 0 0;
  padding:7px 9px;
  border-left:3px solid #b54708;
  background:#fff7ed;
  color:#7c2d12;
  font-size:9px;
  line-height:1.35;
}

@media (max-width:560px){
  .rch-scope-editor__reference-actions{
    grid-template-columns:1fr;
  }
}


/* C.4C.5 — read-only evidence leak diagnostics */
.rch-scope-editor__evidence{
  margin-top:10px;
  padding:10px;
  border:1px solid #eaecf0;
  border-radius:10px;
  background:#fff;
}

.rch-scope-editor__evidence-head{
  display:flex;
  align-items:flex-start;
  justify-content:space-between;
  gap:10px;
  margin-bottom:8px;
}

.rch-scope-editor__evidence-head>span{
  font-size:9px;
  font-weight:700;
  text-align:right;
}

.rch-scope-editor__evidence-head>span.is-warning{color:#b54708;}
.rch-scope-editor__evidence-head>span.is-ok{color:#027a48;}

.rch-scope-editor__evidence-metrics{
  display:grid;
  grid-template-columns:repeat(3,minmax(0,1fr));
  gap:6px;
  margin-bottom:8px;
}

.rch-scope-editor__evidence-list{
  display:grid;
  gap:5px;
}

.rch-scope-editor__evidence-row{
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:10px;
  padding:6px 8px;
  border:1px solid #eaecf0;
  border-radius:8px;
  background:#f9fafb;
  font-size:9px;
  line-height:1.3;
}

.rch-scope-editor__evidence-row>span:first-child{
  display:flex;
  flex-direction:column;
  min-width:0;
}

.rch-scope-editor__evidence-row small{
  color:#667085;
}

.rch-scope-editor__evidence-row.is-leak{
  border-color:#fedf89;
  background:#fffaeb;
  color:#93370d;
}

.rch-scope-editor__evidence-row.is-missing{
  border-style:dashed;
  color:#475467;
}

.rch-scope-editor__evidence-row.is-ok{
  border-color:#abefc6;
  background:#ecfdf3;
}

@media (max-width:560px){
  .rch-scope-editor__evidence-head,
  .rch-scope-editor__evidence-row{
    align-items:flex-start;
    flex-direction:column;
  }

  .rch-scope-editor__evidence-head>span{
    text-align:left;
  }

  .rch-scope-editor__evidence-metrics{
    grid-template-columns:1fr;
  }
}


/* C.4C.6 — explicit manual geometry review session */
.rch-scope-editor__geometry-session{
  display:grid;
  gap:8px;
  margin-top:10px;
  padding:10px 11px;
  border:1px solid #bdb4fe;
  border-radius:11px;
  background:#f5f3ff;
}

.rch-scope-editor__geometry-session[hidden]{display:none!important}

.rch-scope-editor__geometry-session>div:first-child{
  display:grid;
  gap:2px;
}

.rch-scope-editor__geometry-session strong{
  color:#5925dc;
  font-size:10px;
}

.rch-scope-editor__geometry-session small{
  color:#667085;
  font-size:9px;
  line-height:1.35;
}

.rch-scope-editor__geometry-session>div:last-child{
  display:grid;
  grid-template-columns:1fr 1fr;
  gap:7px;
}

@media (max-width:560px){
  .rch-scope-editor__geometry-session>div:last-child{
    grid-template-columns:1fr;
  }
}

/* C.4C.7 — immutable scope revision history */
.rch-scope-editor__history{
  margin-top:10px;
  padding:10px 11px;
  border:1px solid #e4e7ec;
  border-radius:11px;
  background:#fff;
}

.rch-scope-editor__history-head{
  display:flex;
  align-items:flex-start;
  justify-content:space-between;
  gap:8px;
  margin-bottom:8px;
}

.rch-scope-editor__history-head strong{
  font-size:11px;
  color:#101828;
}

.rch-scope-editor__history-head span{
  color:#667085;
  font-size:9px;
  text-align:right;
}

.rch-scope-editor__history-list{
  display:grid;
  gap:5px;
}

.rch-scope-editor__history-list>.muted{
  margin:0;
  font-size:9px;
  line-height:1.4;
}

.rch-scope-editor__history-row{
  display:grid;
  grid-template-columns:minmax(0,1fr) auto;
  gap:10px;
  align-items:center;
  padding:7px 8px;
  border:1px solid #eaecf0;
  border-radius:8px;
  background:#f9fafb;
}

.rch-scope-editor__history-row>span{
  display:grid;
  gap:2px;
  min-width:0;
}

.rch-scope-editor__history-row>span:last-child{
  text-align:right;
}

.rch-scope-editor__history-row strong{
  overflow-wrap:anywhere;
  color:#344054;
  font-size:9px;
  line-height:1.3;
}

.rch-scope-editor__history-row small{
  color:#667085;
  font-size:8px;
  line-height:1.3;
}

@media (max-width:560px){
  .rch-scope-editor__history-head{
    flex-direction:column;
  }

  .rch-scope-editor__history-head span{
    text-align:left;
  }

  .rch-scope-editor__history-row{
    grid-template-columns:1fr;
  }

  .rch-scope-editor__history-row>span:last-child{
    text-align:left;
  }
}


/* C.4C.8 — source-derived read-only trace */
.rch-scope-editor__source-trace{
  display:grid;
  gap:7px;
  margin-top:10px;
  padding:10px 11px;
  border:1px solid #b2ccff;
  border-radius:11px;
  background:#eff8ff;
}
.rch-scope-editor__source-trace p{
  margin:0;
  color:#475467;
  font-size:9px;
  line-height:1.45;
}
.rch-scope-editor__source-trace .rch-scope-editor__toggle{
  padding:0;
  border:0;
  background:transparent;
}

/* C.4C.8.1 — GAP-NORTH review aid */
.rch-scope-editor__source-actions{
  display:flex;
  flex-wrap:wrap;
  gap:7px;
}
.rch-scope-editor__gap-review{
  display:grid;
  gap:4px;
  padding:8px 9px;
  border:1px solid #fecdca;
  border-radius:9px;
  background:#fff6f5;
}
.rch-scope-editor__gap-review strong{
  color:#912018;
  font-size:10px;
  line-height:1.35;
}
.rch-scope-editor__gap-review small{
  color:#b42318;
  font-size:8px;
  line-height:1.4;
}
.rch-scope-editor__gap-review p{
  color:#7a271a;
}
@media (max-width:560px){
  .rch-scope-editor__source-actions{
    display:grid;
    grid-template-columns:1fr;
  }
  .rch-scope-editor__source-actions .btn{
    width:100%;
  }
}


/* C.4C.8.2 — provisional IKEA envelope */
.rch-scope-editor__provisional-card{
  display:grid;
  grid-template-columns:minmax(0,1fr) auto;
  gap:10px;
  align-items:center;
  padding:9px 10px;
  border:1px solid #fdb022;
  border-radius:10px;
  background:#fffaeb;
}
.rch-scope-editor__provisional-card>span{
  display:grid;
  gap:3px;
  min-width:0;
}
.rch-scope-editor__provisional-card strong{
  color:#93370d;
  font-size:10px;
}
.rch-scope-editor__provisional-card small{
  color:#b54708;
  font-size:8px;
  line-height:1.4;
}
.rch-scope-editor__provisional-anchor{
  display:grid;
  gap:4px;
  margin-top:8px;
  padding:8px 9px;
  border:1px solid #eaecf0;
  border-radius:9px;
  background:#f9fafb;
}
.rch-scope-editor__provisional-anchor strong{
  font-size:10px;
}
.rch-scope-editor__provisional-anchor span,
.rch-scope-editor__provisional-anchor small{
  font-size:9px;
  line-height:1.35;
}
.rch-scope-editor__provisional-anchor.is-ok{
  border-color:#abefc6;
  background:#ecfdf3;
  color:#05603a;
}
.rch-scope-editor__provisional-anchor.is-warning{
  border-color:#fedf89;
  background:#fffaeb;
  color:#93370d;
}
@media (max-width:560px){
  .rch-scope-editor__provisional-card{
    grid-template-columns:1fr;
  }
  .rch-scope-editor__provisional-card .btn{
    width:100%;
  }
}
