/* ============================================================
   SEMS — บริบทการทำงาน (ปุ่มบนแถบบน + popup เลือก)
   ============================================================ */

/* ---------- ปุ่มบนแถบบน ---------- */
.ctx-btn{
  display:inline-flex; align-items:center; gap:8px;
  background:var(--bg-raised); border:1px solid var(--line-strong); color:var(--ink);
  border-radius:9px; padding:7px 12px; font-family:var(--sans); font-size:12px;
  font-weight:600; cursor:pointer; max-width:340px;
}
.ctx-btn:hover{ border-color:var(--amber); color:var(--amber); }
.ctx-btn.unset{ border-color:var(--amber); color:var(--amber); border-style:dashed; }

.ctx-btn .ctx-ico{ font-size:13px; line-height:1; flex:none; }
.ctx-btn .ctx-text{ overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }
.ctx-btn .ctx-caret{ font-size:9px; opacity:.6; flex:none; }

/* ---------- popup ---------- */
.ctx-overlay{
  position:fixed; inset:0; z-index:120;
  background:rgba(8,11,14,0.72); backdrop-filter:blur(3px);
  display:none; align-items:center; justify-content:center; padding:20px;
}
.ctx-overlay.on{ display:flex; }

.ctx-modal{
  background:var(--bg-panel); border:1px solid var(--line-strong); border-radius:16px;
  width:100%; max-width:620px; max-height:88vh; display:flex; flex-direction:column;
  box-shadow:0 26px 70px rgba(0,0,0,.5);
}

.ctx-head{ padding:22px 24px 16px; border-bottom:1px solid var(--line); }
.ctx-head h3{ margin:0 0 6px; font-size:17px; font-weight:800; color:var(--ink); }
.ctx-head p{ margin:0; font-size:12.5px; color:var(--ink-dim); line-height:1.55; }

.ctx-body{ padding:20px 24px; overflow-y:auto; flex:1; }
.ctx-loading{ padding:36px 0; text-align:center; color:var(--ink-dim); font-size:13px; }

/* ---------- 3 ช่องเรียงแถวเดียว ---------- */
.ctx-row{ display:flex; gap:14px; align-items:flex-start; }
.ctx-col{ flex:1; min-width:0; display:flex; flex-direction:column; gap:8px; }

.ctx-col label{
  display:flex; align-items:center; gap:7px;
  font-size:12px; font-weight:700; color:var(--ink-dim);
  white-space:nowrap; overflow:hidden; text-overflow:ellipsis;
}
.ctx-col label span{ font-size:14px; flex:none; }

.ctx-col select{
  width:100%; background:var(--bg-raised);
  border:1px solid var(--line-strong); color:var(--ink);
  border-radius:10px; padding:11px 12px;
  font-family:var(--sans); font-size:13.5px; cursor:pointer;
}
.ctx-col select:focus{ outline:none; border-color:var(--amber); }
.ctx-col select:invalid, .ctx-col select[value=""]{ color:var(--ink-faint); }

.ctx-empty{ font-size:11px; color:var(--amber); line-height:1.5; }

.ctx-foot{
  padding:16px 24px; border-top:1px solid var(--line);
  display:flex; align-items:center; justify-content:space-between; gap:14px; flex-wrap:wrap;
}
.ctx-hint{ font-size:11.5px; color:var(--ink-dim); font-family:var(--mono); }
.ctx-hint.warn{ color:var(--amber); }
.ctx-actions{ display:flex; gap:9px; }

/* ---------- จอเล็ก ---------- */
@media (max-width:640px){
  .ctx-row{ flex-direction:column; gap:16px; }
}

@media (max-width:600px){
  .ctx-btn{ max-width:170px; padding:6px 10px; }
  .ctx-btn .ctx-text{ font-size:11px; }
  .ctx-modal{ max-height:92vh; }
  .ctx-head{ padding:18px 18px 14px; }
  .ctx-body{ padding:16px 18px; }
  .ctx-foot{ padding:14px 18px; }
  .ctx-actions{ width:100%; }
  .ctx-actions .btn{ flex:1; }
}
